#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; vector> XY( M ); for( int i = 0; i < M; i++ ) { int X, Y; cin >> X >> Y; XY[i] = make_tuple( X, Y, i ); } sort( XY.begin(), XY.end() ); vector v( M ); for( int i = 0; i < N; i++ ) { int j = upper_bound( XY.begin(), XY.end(), make_tuple( A[i], 100000000, M - 1 ) ) - XY.begin(); for( j--; j >= 0; j-- ) { if( get<1>( XY[j] ) < B[i] ) continue; int k = get<2>( XY[j] ); v[k]++; } } int ma = *max_element( v.begin(), v.end() ); if( ma == 0 ) { cout << 0 << endl; } else { for( int i = 0; i < M; i++ ) { if( v[i] < ma ) continue; cout << i + 1 << endl; } } }