#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long #define mod 1000000007 int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); int N,Q; pair AB[200009]; cin>>N; for(int i=1;i<=N;i++) cin>>AB[i].first>>AB[i].second; sort(AB+1,AB+N+1); cin>>Q; tuplexy[200009]; for(int i=1;i<=Q;i++){ cin>>get<0>(xy[i])>>get<1>(xy[i]); get<2>(xy[i])=i; } sort(xy+1,xy+Q+1); ll ans[200009]; ll ng[100009]; for(int i=1;i<=100000;i++) ng[i]=0; ll pos=1; AB[N+1]={2e18,2e18}; for(int i=1;i<=Q;i++){ while(AB[pos].first<=get<0>(xy[i])){ ng[AB[pos].second]++; pos++; } ans[get<2>(xy[i])]=pos-ng[get<1>(xy[i])]-1; } for(int i=1;i<=Q;i++) cout<