#include #include #include #include using namespace std; int main() { int N; cin >> N; array as{}; array bs{}; for (int i = 0; i < N; ++i) { long a, b; cin >> a >> b; as[i] = a; bs[i] = b; } int M; cin >> M; array xs{}; array ys{}; for (int j = 0; j < M; ++j) { long x, y; cin >> x >> y; xs[j] = x; ys[j] = y; } vector counters(M, 0); 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; }