#include #include #include #include using namespace std; int main() { int N; cin >> N; vector as(N); vector bs(N); for (int i = 0; i < N; ++i) { cin >> as[i] >> bs[i]; } int M; cin >> M; vector xs(M); vector ys(M); for (int j = 0; j < M; ++j) { cin >> xs[j] >> ys[j]; } vector counters(M); for (int k = 0; k < M; ++k) { for (int i = 0; i < N; ++i) { if (xs[k] <= as[i] && ys[k] >= bs[i]) { counters[k] += 1; } } } int maxElem = *std::max_element(counters.begin(), counters.end()); if (maxElem == 0) { cout << 0 << endl; return 0; } for (int l = 0; l < M; ++l) { if (counters[l] == maxElem) { cout << (l + 1) << endl; } } cout << "\n"; return 0; }