#include using namespace std; typedef long long ll; struct member { int a, b; member() {}; member(int a_, int b_): a(a_), b(b_) {}; }; struct codroe { int x, y, id; codroe() {}; codroe(int x_, int y_, int id_): x(x_), y(y_), id(id_) {}; }; int main() { int n; cin >> n; vector members; for (int i = 0; i < n; ++i) { int a, b; cin >> a >> b; members.emplace_back(a, b); } int m; cin >> m; vector codroes; for (int i = 0; i < m; ++i) { int x, y; cin >> x >> y; codroes.emplace_back(x, y, i); } vector counts(m, 0); for (member mem: members) { for (codroe cod: codroes) { if (cod.x <= mem.a && cod.y >= mem.b) counts[cod.id]++; } } int ma = *max_element(counts.begin(), counts.end()); if (ma == 0) { cout << 0 << '\n'; } else { for (int i = 0; i < m; ++i) { if (counts[i] == ma) { cout << i + 1 << '\n'; } } } return 0; }