#include #include #include #include #define REP(i, n) for (int i = 0; i < n; i++) using namespace std; int main(void) { int N; cin>>N; vector A,B; REP(i, N) { int a,b; cin>>a>>b; A.push_back(a); B.push_back(b); } int M; cin>>M; map mp; REP(i, M) { int X,Y; cin>>X>>Y; REP(j, N) { if (A.at(j) < X || B.at(j) > Y) continue; if (mp.find(i) != mp.end()) mp[i] += 1; else mp[i] = 1; } } vector test; for (map::iterator it = mp.begin(); it != mp.end(); ++it) test.push_back(it->second); if (test.size() == 0) { cout << 0 << endl; return 0; } sort(test.begin(), test.end()); int maximum = test.at(test.size() - 1); for (map::iterator it = mp.begin() ; it != mp.end(); ++it) { if (it->second == maximum) cout << it->first + 1 << endl; } return 0; }