#include #define PI 3.14159265359 using namespace std; int main() { int N, M; cin >> N; vector> v(N); for (int i = 0; i < N; i++) { cin >> v.at(i).first >> v.at(i).second; } cin >> M; //cout << "M:" << M << endl; vector v2(M); int max = 0; for (int i = 0; i < M; i++) { int x, y; cin >> x >> y; //cout << "x:" << x << ' ' << "y:" << y << endl; for (int j = 0; j < N; j++) { int a, b; a = v.at(j).first; b = v.at(j).second; //cout << "a:" << a << ' ' << "b:" << b << endl; if ((x <= a) && (y >= b)) v2.at(i)++; if (v2.at(i) > max) max = v2.at(i); } } if (!max) { cout << 0 << endl; return 0; } for (int i = 0; i < M; i++) { //cout << v2.at(i) << endl; if (v2.at(i) == max) { cout << i + 1 << endl; } } }