using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int umax = 100020; List[] L = new List[umax]; for(int i=0;i(); for(int i=0;i0){ L[i].Sort( (a,b) => { if(a.S.CompareTo(b.S) != 0) return - a.S.CompareTo(b.S); // descend return a.P.CompareTo(b.P);// ascend }); } } for(int i=0;i { if(a.S.CompareTo(b.S) != 0) return - a.S.CompareTo(b.S); // descend if(a.Ord.CompareTo(b.Ord) != 0) return a.S.CompareTo(b.Ord); // ascend return a.P.CompareTo(b.P); // ascend }); //for(int i=0;iint.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }