/* Bismillah * Author: Akhyar Ahmed Turk * Created: 2025-12-29 13:43 (GMT+5) * brain["Motivation"].insert("Ya to win hy ya learn"); * Those who can't remember the past are condemned to repeat it. * -Dynamic Programming. */ #include #include #include using namespace std; using namespace __gnu_pbds; template using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>; // use when u need indexing in sets like (when you need lower upper bound while frequently updating set) // idx.order_of_key(value) for nums #define pb push_back #define f first #define ss second #define vi vector #define vb vector #define vvi vector #define all(a) a.begin(), a.end() #define allr(a) a.rbegin(), a.rend() #define mod 1000000007 #define mod2 998244353 const int inf = 1e17 + 1; #define INT_MAX LLONG_MAX #define nl "\n" #define forn(i, a, b) for (int i = a; i < b; i++) #define forr(i, a, b) for (int i = a; i >= b; i--) #define input(vec, n) for(int z = 0; z < (n); z++) cin >> vec[z]; void solve() { int n; cin>>n; vi mp(n); vector mp2(1e5+1); forn(i,0,n){ int a,b; cin>>a>>b; mp[i]=a; mp2[b].pb(a); } sort(all(mp)); for(auto &it:mp2) sort(all(it)); int q; cin>>q; while(q--){ int a,b; cin>>a>>b; int res=upper_bound(all(mp),a)-mp.begin(); int r2=upper_bound(all(mp2[b]),a)-mp2[b].begin(); cout<> t; while (t--) { solve(); } return 0; }