#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const double EPS = 1e-9; typedef vector vec; typedef pair P; #define rep(n) REP(i, 0, n) #define ALL(v) v.begin(), v.end() #define in(a) cin >> a; #define out(a) cout << a << endl; #define REP(i, x, n) for(int i = x; i < n; i++) #define INF 100000000 int dy[] = { 1,0,-1,0 }, dx[] = { 0,1,0,-1 }; int main() { int n, m, mcnt = 0; cin >> n; int x[1005] = { 0 }, y[1005] = { 0 }, a[1005] = { 0 }, b[1005] = { 0 }; int menn[1005] = { 0 }; for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; cin >> m; for (int i = 0; i < m; i++) cin >> x[i] >> y[i]; for (int i = 0; i < m; i++) { int cnt = 0; for (int j = 0; j < n; j++) { if (x[i] <= a[j] && y[i] >= b[j]) cnt++; } mcnt = max(mcnt, cnt); menn[i] = cnt; } if (mcnt == 0) { cout << "0" << endl; return 0; } for (int i = 0; i < m; i++) { //cout << menn[i] << endl; if (menn[i] == mcnt) cout << i + 1 << endl; } return 0; }