import java.util.Scanner; public class Main { static int count=0; public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int a[]=new int[n]; int b[]=new int[n]; int t=0; for(int i=0;i<n;i++) { a[i]=input.nextInt(); b[i]=input.nextInt(); if(a[i]==0) t++; } input.close(); if(t!=0) { int tag=0; int flg=0; for(int i=0;i<n;i++) { int cnt=0; if(a[i]!=0) { for(int j=0;j<n;j++) { if(i==j) continue; if(a[i]==a[j]) cnt++; if(a[j]==a[i]+1) cnt=0; } if(cnt>=a[i] && flg<=a[i]) { System.out.print(i+1); flg++; } } else { for(int j=0;j<n;j++) if(a[j]==1) tag++; if(tag==0) { System.out.println(i+1); tag=-1; } } } if(flg==0 && tag!=-1) System.out.println("NoSolution"); } else System.out.println(0); } } /************************************************************** Problem: 1865 User: admin Language: Java Result: Accepted Time:4179 ms Memory:40344 kb ****************************************************************/