#include #include #include using namespace std; int main() { int n; cin >> n; vector> v1(n, vector(2)); for (int i=0; i> v1[i][0] >> v1[i][1]; } int m; cin >> m; vector> v2(m, vector(4)); for (int i=0; i> v2[i][2] >> v2[i][3]; v2[i][1]=i+1; } for (int i=0; i=v1[j][1]) v2[i][0]++; } } sort(v2.begin(), v2.end(), [](auto &L, auto &R){return L[0]==R[0] ? L[1]R[0];}); int max=v2[0][0]; if (!max) { cout << 0 << endl; return 0; } else { for (int i=0; i