#include #include #include #include #include #include #include using namespace std; int main() { 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 c(m); for (int j = 0; j < m; j++) { int x, y; cin >> x >> y; for (int i = 0; i < n; i++) { if (x <= a[i] && y >= b[i]) c[j]++; } } int r = 0; for (int j = 0; j < m; j++) { r = max(r, c[j]); } if (r == 0) { cout << 0 << endl; } else { for (int j = 0; j < m; j++) { if (c[j] == r) cout << j + 1 << '\n'; } } return 0; }