import java.util.*; public class Main { static final long MAX = (long)Math.sqrt(Long.MAX_VALUE); public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] costs = new int[n]; int[] hots = new int[n]; for (int i = 0; i < n; i++) { costs[i] = sc.nextInt(); hots[i] = sc.nextInt(); } int m = sc.nextInt(); int[] counts = new int[m]; for (int i = 0; i < m; i++) { int c = sc.nextInt(); int h = sc.nextInt(); for (int j = 0; j < n; j++) { if (c <= costs[j] && h >= hots[j]) { counts[i]++; } } } int max = 0; ArrayList list = new ArrayList<>(); for (int i = 0; i < m; i++) { if (counts[i] > max) { list.clear(); list.add(i + 1); max = counts[i]; } else if (counts[i] == max) { list.add(i + 1); } } if (max == 0) { System.out.println(0); return; } StringBuilder sb = new StringBuilder(); for (int x : list) { sb.append(x).append("\n"); } System.out.print(sb); } }