#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; vector> v(n); rep(i, n) cin >> v[i].first >> v[i].second; int m; cin >> m; vector cnt(m, 0); rep(i, m) { int x, y; cin >> x >> y; for (auto [a, b] : v) { if (x <= a && y >= b) cnt[i]++; } } int maxim = *max_element(cnt.begin(), cnt.end()); if (maxim == 0) { cout << 0 << endl; } else { rep(i, m) { if (cnt[i] == maxim) cout << i + 1 << endl; } } return 0; }