using System.Linq; using System.Collections.Generic; using System; public class P { public int x { get; set; } public int y { get; set; } public int id { get; set; } } public class Hello { public static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var a = new int[n, 2]; for (int i = 0; i < n; i++) { string[] line = Console.ReadLine().Trim().Split(' '); a[i, 0] = int.Parse(line[0]); a[i, 1] = int.Parse(line[1]); } var m = int.Parse(Console.ReadLine().Trim()); var ps = new P[m]; for (int i = 0; i < m; i++) { string[] line = Console.ReadLine().Trim().Split(' '); var x = int.Parse(line[0]); var y = int.Parse(line[1]); ps[i] = new P { id = i, x = x, y = y }; } var ps2 = ps.OrderBy(z => z.x).ToArray(); printAns(a, ps2); } public static void printAns(int[,] a, P[] b) { var ans = new List(); var n = a.GetLength(0); var m = b.Length; var buy = new int[m]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { if (b[j].x > a[i, 0]) break; if (b[j].y >= a[i, 1]) buy[b[j].id]++; } var max = buy.Max(); if (max == 0) { Console.WriteLine(0); return; } for (int i = 0; i < m; i++) if (buy[i] == max) Console.WriteLine(i + 1); } }