#include #include #include #include int main() { //std::ifstream inf("Text.txt"); std::cin.rdbuf(inf.rdbuf()); int N; std::cin >> N; std::vector A(N), B(N); int max_price = 0; int min_hot = 100000000; for (int i = 0; i < N; i++) { std::cin >> A[i] >> B[i]; if (A[i] > max_price) { max_price = A[i]; } if (B[i] < min_hot) { min_hot = B[i]; } } int M; std::cin >> M; std::vector X(M), Y(M), ans(M); for (int i = 0; i < M; i++) { std::cin >> X[i] >> Y[i]; } for (int i = 0; i < M; i++) { if (X[i] > max_price) { continue; } if (Y[i] < min_hot) { continue; } for (int j = 0; j < N; j++) { if (X[i] <= A[j]) { if (Y[i] >= B[j]) { ans[i]++; } } } } int max = *std::max_element(ans.begin(), ans.end()); if (max != 0) { for (int i = 0; i < M; i++) { if (ans[i] == max) { std::cout << i + 1 << std::endl; } } } else { std::cout << "0" << std::endl; } return 0; }