#include using namespace std; template T gcd(T x, T y) { if (y == 0) return x; return gcd(y, x % y); } template T lcm(T x, T y) { if (x == 0 || y == 0) return 0; return x / gcd(x, y) * y; } int main() { int N; cin >> N; vector A(N), B(N); for (int i = 0; i < N; i++) cin >> A[i] >> B[i]; int M; cin >> M; vector cnt(M); long m = 0; for (int i = 0; i < M; i++) { int X, Y; cin >> X >> Y; for (int j = 0; j < N; j++) { if (X <= A[j] && B[j] <= Y) cnt[i]++; m = max(m, cnt[i]); } } if (m == 0) { cout << 0 << endl; return 0; } for (int i = 0; i < M; i++) { if (cnt[i] == m) cout << i + 1 << endl; } }