#include using namespace std; typedef long long LL; typedef vector VI; typedef pair PI; int main() { int n; cin >> n; VI a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } int m; cin >> m; int ma = 0; map mp; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; for (int j = 0; j < n; j++) { if (x <= a[j] && y >= b[j]) { mp[i]++; ma = max(ma, mp[i]); } } } if (mp.size()) { for (auto e : mp) if(e.second == ma) cout << e.first + 1 << endl; } else { cout << 0 << endl; } return 0; }