#include using namespace std; using i64 = long long; #define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++) int N; int M; vector X,Y; vector A,B; int main(){ cin >> N; A.resize(N); B.resize(N); rep(i,0,N - 1){ cin >> A[i] >> B[i]; } cin >> M; X.resize(M); Y.resize(M); rep(i,0,M - 1){ cin >> X[i] >> Y[i]; } vector ans(M,0); rep(i,0,N - 1){ rep(j,0,M - 1){ if(A[i] >= X[j] && B[i] <= Y[j]) ans[j]++; } } int a = max_element(ans.begin(),ans.end()) - ans.begin(); if(ans[a] == 0){ cout << 0 << endl; } else{ rep(i,0,M - 1){ if(ans[i] == ans[a]){ cout << i + 1 << endl; } } } }