#include #include #include using namespace std; typedef long long lint; typedef vectorvi; typedef pairpii; #define rep(i,n)for(int i=0;i<(int)(n);++i) int main(){ int n; cin>>n; vi a(n),b(n); rep(i,n)cin>>a[i]>>b[i]; int m; cin>>m; vi x(m),y(m),c(m); rep(i,m)cin>>x[i]>>y[i]; rep(i,n){ rep(j,m){ if(x[j]<=a[i]&&y[j]>=b[i])c[j]++; } } vectort; rep(i,m){ t.push_back(pii(-c[i],i+1)); } sort(t.begin(),t.end()); int cnt=0; rep(i,m){ if(i==0||t[i].first==t[i-1].first){ cout<