import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] prices = new int[n]; int[] hots = new int[n]; for (int i = 0; i < n; i++) { prices[i] = sc.nextInt(); hots[i] = sc.nextInt(); } int m = sc.nextInt(); Mentai[] mentais = new Mentai[m]; for (int i = 0; i < m; i++) { mentais[i] = new Mentai(i + 1, sc.nextInt(), sc.nextInt()); for (int j = 0; j < n; j++) { mentais[i].buy(prices[j], hots[j]); } } Arrays.sort(mentais); int count = mentais[0].count; if (count == 0) { System.out.println(0); return; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < m && mentais[i].count == count; i++) { sb.append(mentais[i].idx).append("\n"); } System.out.print(sb); } static class Mentai implements Comparable { int idx; int price; int hot; int count; public Mentai (int idx, int price, int hot) { this.idx = idx; this.price = price; this.hot = hot; count = 0; } public int compareTo(Mentai another) { if (count == another.count) { return idx - another.idx; } else { return another.count - count; } } public void buy(int p, int h) { if (p >= price && h <= hot) { count++; } } } }