#include using namespace std; #define rep(i,a,b) for(int i=a;i>N; vector> p(90); rep(i,0,N){ int x,y; cin>>x>>y; int A=(x%9)*10+(x*5+y)%10; p[A].push_back(i+1); } for(auto x:p){ if(N<=90*(int)(x.size())){ cout<