#include<iostream> #include<algorithm> #include<map> using namespace std; typedef struct ps { public: int first; int second; }ps; class opt { public: bool operator() (const ps &s1, const ps &s2) { int a = s1.first * s2.second; int b = s1.second * s2.first; return a < b; } }; int main() { int cs, line, t, s, key, val; ps p; multimap<ps, int, opt> mm; multimap<ps, int, opt>::iterator it; cin>>cs; while(cs--) { cin>>line; for(int i=0; i<line; i++) { cin>>t>>s; p.first = t; p.second = s; mm.insert(make_pair(p, i+1)); } for(it = mm.begin(); it != mm.end(); ++it) cout<<it->second<<" "; cout<<endl<<endl; mm.clear(); } return 0; }