#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #define rep(i,n) for(int i=0;i<(n);i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) ((int)(x).size()) #define pb push_back using ll = long long; using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N; vector A(N); vector B(N); rep(i,N) cin >> A[i] >> B[i]; int M; cin >> M; vector X(M); vector Y(M); rep(i,M) cin >> X[i] >> Y[i]; vector cnt(M,0); rep(i,N){ rep(j,M){ if(A[i]>=X[j]&&B[i]<=Y[j]) cnt[j]++; } } int mx = *max_element(all(cnt)); if(mx==0) cout << 0 << endl; else{ rep(j,M) if(cnt[j]==mx) cout << j+1 << endl; } return 0; }