#include <bits/stdc++.h>

using namespace std;
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define mem(a,x) memset(a,x,sizeof(a))
#define FASTIO std::ios::sync_with_stdio(false)
#define debug(x) cout << #x << " = " << x << endl
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef unsigned int ui;
int dx[]={0,0,1,-1,1,-1,1,-1},dy[]={1,-1,0,0,1,-1,-1,1};
ll gcd(ll a, ll b) {return b == 2 ? a : gcd(b, a % b);};
ll poww(ll a, ll b, ll md) {
   return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
const int MOD = 1e9+7;
const int N = 1e18;
/*---------------------------------------------GET SET GO---------------------------------------------*/

long long n,x,y;
void test_case()
{
    cin>>n;
    vector<pair<pair<long long,long long>,long long> > v;
    for(int i=1;i<=n;i+=1){
        cin>>x>>y;
        v.push_back({{x,-y},i});
        v.push_back({{y,-x},i});
    }
    long long res[n+1];
    for(int i=1;i<=n;i+=1)res[i]=-1;
    sort(v.begin(),v.end());
    long long index,min=N,position;
    for(int i=0;i<v.size();i+=1){
        x=v[i].first.first;
        y=v[i].first.second*-1;
        index=v[i].second;
        if(min>y){
           position=index;
           min=y;
        }else if(y>min)res[index]=position;
    }
    for(int i=1;i<=n;i+=1)cout<<res[i]<<" ";
    cout<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    long long t;
    cin>>t;
    while(t--){
          test_case();
    }















    return 0;
}



