#include #define ll long long #define int long long #define double long double #define float double #define pb push_back #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define nl '\n' #define here cout << "HERE" << endl; #define forn(i, a, n) for (int i = a; i < n; i++) #define print(a) for (auto& e : a) cout << e << " "; cout << endl; #define MOD(a, b) (((a) % (b) + (b)) % (b)) #define yesno(b) cout << ((b) ? "YES\n" : "NO\n") #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; using vi = vector; // sort challenges and find lower bound to get number of possible challenges // get upper bound of challenges array // difference is answer void solve(){ int n; cin>>n; vector> challenges(n); vector arr(2e5); forn(i,0,n){ cin>>challenges[i].first>>challenges[i].second; } sort(all(challenges)); forn(i,0,n){ arr[challenges[i].second].pb(challenges[i].first); } for(auto &array:arr){ if(!arr.empty())sort(all(array)); } int q; cin>>q; vector> heros(q); forn(i,0,q){ cin>>heros[i].first>>heros[i].second; int total=lower_bound(all(challenges),make_pair(heros[i].first,LLONG_MAX))-challenges.begin(); int cantdo=upper_bound(all(arr[heros[i].second]),heros[i].first) - arr[heros[i].second].begin(); cout<> t; while (t--) solve(); return 0; }