#include #include #include using namespace std; #define FOR(i, a, n) for (int i = a; i < n; i++) #define REP(i, n) for(int i = 0; i < n; i++) int main(){ int n; cin >> n; int A[n], B[n]; REP(i, n) cin >> A[i] >> B[i]; int m; cin >> m; int X[m], Y[m]; REP(i, m) cin >> X[i] >> Y[i]; int T[m] = {}; REP(i, n){ REP(j, m){ if(A[i] >= X[j] and B[i] <= Y[j]){ T[j]++; } } } vector V; int ma = 0; REP(i, m){ if(T[i] > ma and T[i] != 0){ V.clear(); V.push_back(i + 1); ma = T[i]; }else if(T[i] == ma and T[i] != 0){ V.push_back(i + 1); } } if(V.size()){ REP(i, V.size()){ cout << V[i] << endl; } }else cout << 0 << endl; return 0; }