#include using namespace std; bool comp(const pair x, const pair y) { if(x.first != y.first) return x.first > y.first; else return x.second < y.second; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n), b(n); for(int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } int m; cin >> m; vector x(m), y(m); for(int i = 0; i < m; i++) { cin >> x[i] >> y[i]; } vector> z(m); for(int i = 0; i < m; i++) { z[i].first = 0; z[i].second = i; } for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(x[j] <= a[i] && y[j] >= b[i]) z[j].first++; } } sort(z.begin(), z.end(), comp); int mx = z[0].first; if(mx == 0) { cout << 0 << endl; return 0; } for(int i = 0; i < m; i++) { if(z[i].first == mx) { cout << z[i].second + 1 << '\n'; } } return 0; }