package m.shin; import java.util.Scanner; public class Con647 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); int[][] ab = new int[N][2]; for(int i = 0;i < N;i++){ ab[i][0] = s.nextInt(); ab[i][1] = s.nextInt(); } int M = s.nextInt(); int[] count = new int[M]; for(int i = 0;i < M;i++){ int x = s.nextInt() , y = s.nextInt(); for(int j = 0;j < N;j++){ if(ab[j][0] >= x && ab[j][1] <= y){ count[i]++; } } } s.close(); N = 0; for(int i = 0;i < 2;i++){ for(int j = 0;j < M;j++){ if(i == 0){ if(count[j] >= count[N]){ N = j; } }else{ if(count[j] ==count[N] && count[N] != 0){ System.out.println(j+1); }else if(count[N] == 0){ System.out.println(0); break; //未完成 } } } } } }