using System; using System.Collections; using System.Collections.Generic; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ Array.Sort(P,(x,y)=>x.T>y.T?1:x.T[] H=new HashSet[2]; H[0]=new HashSet(); H[0].Add(0); int now=0; int next=1; for(int i=0;i(); int maxx=0; foreach(int v in H[now]){ //Console.WriteLine("{0} {1}",i,v); if(v>=10002){ maxx=Math.Max(maxx,v); }else{ if(vint.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} }