#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define INF 1e9 #define MAX_N 10000 #define MAX_M 1000 using namespace std; typedef long long ll; typedef pair P; int main() { int N, M, A[MAX_N], B[MAX_N], X[MAX_M], Y[MAX_M]; cin >> N; for (int i = 0; i < N; ++i) cin >> A[i] >> B[i]; cin >> M; for (int i = 0; i < M; ++i) cin >> X[i] >> Y[i]; int num[MAX_M]; fill(num, num + MAX_M, 0); for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) if (A[i] >= X[j] && B[i] <= Y[j]) ++num[j]; int max_ = 0; for (int i = 0; i < M; ++i) max_ = max(max_, num[i]); if (max_ == 0) cout << 0 << endl; else for (int i = 0; i < M; ++i) if (num[i] == max_) cout << i + 1 << endl; return 0; }