#include using namespace std; using i64=int64_t; #define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i ostream &operator<<(ostream &os, const vector &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ int N; cin >> N; vector A(N),B(N); rep(i,0,N) cin >> A[i] >> B[i]; int M; cin >> M; int ma=1; vector ans; rep(i,0,M){ int X,Y; cin >> X >> Y; int cnt=0; rep(j,0,N) if(X<=A[j] and Y>=B[j]) ++cnt; if(cnt>ma){ ma=cnt; ans.clear(); ans.push_back(i+1); }else if(cnt==ma) ans.push_back(i+1); } if(ans.empty()){ cout << 0 << endl; return; } rep(i,0,ans.size()) cout << ans[i] << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); return 0; }