#include #include #include #include #include using namespace std; int main() { int n; cin >> n; vector A(n); vector B(n); for(int i = 0;i < n;i++){ cin >> A[i] >> B[i]; } int m; cin >> m; int x,y; vector ans(m); int max=0; string anss; for(int i = 0;i < m;i++){ cin >> x >> y; for(int j = 0;j < n;j++){ if(x <= A[j] && y >= B[j])ans[i]++; } if(ans[i] > max){ max = ans[i]; anss = to_string(i+1) + "\n"; } else if(ans[i] == 0 &&ans[i] == max) anss = "0"; else if(ans[i] == max){ max = ans[i]; anss += to_string(i+1) + "\n"; } } cout << anss; return 0; }