using System; using System.Collections.Generic; using System.Linq; namespace _647 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[,] member = new int[n,2]; for (int i = 0; i < n; i++) { int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray(); member[i,0] = x[0]; member[i,1] = x[1]; } int m = int.Parse(Console.ReadLine()); List ret = new List(); int max = 1; for (int i = 0; i < m; i++) { int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray(); int mentai = 0; for (int j = 0; j < n; j++) { if (x[0] <= member[j,0] && member[j,1] <= x[1]) mentai++; } if (mentai > max) ret.Clear(); if (mentai >= max) ret.Add(i + 1); max = Math.Max(max,mentai); } if (ret.Count() == 0) Console.WriteLine(0); else { for (int i = 0; i < ret.Count(); i++) { Console.WriteLine(ret[i]); } } } } }