#include #include #include using namespace std; struct mentaiko{ int cost, spicy; }; int main(){ int N; cin >> N; mentaiko want_mentaikos[N]; for(int i = 0; i < N; i++){ cin >> want_mentaikos[i].cost >> want_mentaikos[i].spicy; } int M; cin >> M; pair mentaiko_bought_counts[M]; for(int i = 0; i < M; i++){ mentaiko this_mentaiko; cin >> this_mentaiko.cost >> this_mentaiko.spicy; int mentaiko_bought_count = 0; for(int j = 0; j < N; j++){ mentaiko_bought_count += (this_mentaiko.cost <= want_mentaikos[j].cost && this_mentaiko.spicy >= want_mentaikos[j].spicy); } mentaiko_bought_counts[i] = {mentaiko_bought_count, i}; } sort(mentaiko_bought_counts, mentaiko_bought_counts + M); if(mentaiko_bought_counts[M - 1].first){ cout << mentaiko_bought_counts[M - 1].second + 1 << endl; for(int i = M - 1; i > 0; i++){ if(mentaiko_bought_counts[i - 1].first == mentaiko_bought_counts[i].first){ cout << mentaiko_bought_counts[i - 1].second + 1 << endl; }else{ return 0; } } }else{ cout << 0 << endl; } }