import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] A = new int[N]; int[] B = new int[N]; int ans = 0; int[] result = new int[N]; int c = 0; for (int i = 0; i < N; i++) { A[i] = sc.nextInt(); B[i] = sc.nextInt(); } int M = sc.nextInt(); int ch = 0; lavel: for (int i = 0; i < M; i++) { int X = sc.nextInt(); int Y = sc.nextInt(); ans=0; for (int j = 0; j < N; j++) { if (X <= A[j] && Y >= B[j]) { ans++; } } if (ch <= ans && ans != 0) { if (ch == ans) { c++; result[c] = i + 1; } else { Arrays.fill(result, 0); ch = ans; c = 0; result[c] = i + 1; } } } for (int i = 0; result[i] != 0 || i == 0; i++) { System.out.println(result[i]); } } }