https://vjudge.net/contest/279730#problem/J
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct str
{
int i,v,d;
bool operator<(const str &str1)const
{
if (d*str1.v==v*str1.d) return i<str1.i;
else return d*str1.v<v*str1.d;
}
}a[100000];
int n,i,t;
int main()
{
scanf("%d",&t);
while (t--)
{
scanf("%d",&n);
for (i=1; i<=n; i++)
{
scanf("%d%d",&a[i].d,&a[i].v);
a[i].i=i;
}
sort(a+1,a+n+1);
for (i=1; i<n; i++)
printf("%d ",a[i].i);
printf("%d\n",a[n]);
if (t) printf("\n");
}
}