using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Program { static void Main() { var N = int.Parse(ReadLine()); var A = new int[N]; var B = new int[N]; for (int i = 0; i < N; i++) { var AB = ReadLine().Split().Select(int.Parse).ToArray(); A[i]=AB[0]; B[i]=AB[1]; } var M =int.Parse(ReadLine()); var X = new int[N]; var Y = new int[N]; for (int i = 0; i < M; i++) { var XY = ReadLine().Split().Select(int.Parse).ToArray(); X[i]=XY[0]; Y[i]=XY[1]; } var c=new int[M]; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if(A[i]>=X[j]&&B[i]<=Y[j])c[j]++; } } foreach (var i in c.Select((x,i)=>x==c.Max()?i:-1).Where(x=>x>-1))WriteLine(i+1); } }