using System; using System.Collections.Generic; using System.Linq; public class Program { static void Main() { List Members = new List(); List Kiseki = new List(); Kiseki.Add(0); int MaxNum = 0; int KaiCount = 0; for(var i = int.Parse(Console.ReadLine()); i>0 ;i--){ Members.Add( Member.MakeMember( Splitter( Console.ReadLine() ).Select( a => int.Parse(a) ).ToList() ) ); } var MembersList = Members.OrderByDescending(a => a.Yosan).ThenBy(a => a.Karasa); int MentaiMax = int.Parse(Console.ReadLine()); List Tmp = new List(); for(var j = 1; j <= MentaiMax ;j++){ KaiCount = 0; Tmp = Splitter( Console.ReadLine() ).Select( a => int.Parse(a) ).ToList(); KaiCount = MembersList.Where(a => a.Kauka(Tmp)).Count(); if(KaiCount > MaxNum){ Kiseki.Clear(); MaxNum = KaiCount; Kiseki.Add(j); }else if(KaiCount == MaxNum && MaxNum != 0){ Kiseki.Add(j); } } foreach(var m in Kiseki){ Console.WriteLine(m); } } static List Splitter(string Input, char Delimiter = ' '){ return new List(Input.Split(Delimiter)); } } public class Member { public int Yosan; public int Karasa; public Member(int InYosan, int InKarasa){ Yosan = InYosan; Karasa = InKarasa; } public bool Kauka(List list){ return (list[0] <= Yosan) && (list[1] >= Karasa); } public static Member MakeMember(List list){ return new Member(list[0],list[1]); } }