#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define rev(a) a.rbegin(),a.rend()
#define all(a) a.begin(),a.end()
#define setbits(x) (__builtin_popcount(x))
#define pi pair<int,int>
#define precise(a,k) cout<<fixed<<setprecision(k)<<a;
#define fill(s,x,n) vector<s> x(n); rep(i,0,n) cin>>x[i];
#define minpq(type) priority_queue<type,vector<type>,greater<type>>
#define debug(...) cerr<<"{ "<<#__VA_ARGS__<<" = "<<(__VA_ARGS__)<<" }"<<endl;
#define debugp(...) cerr<<"{ "<<#__VA_ARGS__<<" = "<<"("<<(__VA_ARGS__).ff<<","<<(__VA_ARGS__).ss<<")"<<" }"<<endl;
#define debugv(...) cerr<<"{ "; for(int i=0; i<size(__VA_ARGS__); i++) cerr<<#__VA_ARGS__<<"["<<i<<"]"<<" = "<<(__VA_ARGS__)[i]<<" ; "; cerr<<"}"<<endl;
#define debugpv(...) cerr<<"{ "; for(int i=0; i<size(__VA_ARGS__); i++) cerr<<#__VA_ARGS__<<"["<<i<<"]"<<" = "<<"("<<(__VA_ARGS__)[i].ff<<","<<(__VA_ARGS__)[i].ss<<")"<<" ; "; cerr<<"}"<<endl;
#define mod 998244353
#define inf 1000000007
#define inf64  1000000000000000005
#define PI 3.141592653589793

void solve(){
    int n;
    cin>>n;
    vector<array<int,2>> req(n);
    vector<array<int,3>> hp(n),wp(n);
    rep(i,0,n){
        int h,w;
        cin>>h>>w;
        hp[i] = {h,w,i+1};
        wp[i] = {w,h,i+1};
        req[i] = {h,w};
    }
    sort(rev(hp));
    sort(rev(wp));
    vector<pi> smhp(n),smwp(n);
    smhp[n-1] = {hp[n-1][1],hp[n-1][2]};
    smwp[n-1] = {wp[n-1][1],wp[n-1][2]};
    rep(i,n-1,0){
        smhp[i] = smhp[i+1];
        smwp[i] = smwp[i+1];
        if(hp[i][1]<smhp[i+1].ff){
            smhp[i] = {hp[i][1],hp[i][2]};
        }
        if(wp[i][1]<smwp[i+1].ff){
            smwp[i] = {wp[i][1],wp[i][2]};
        }
    }
    function<int(int)> binh=[&](int val){
        int l = 0;
        int h = n;
        while(l<h){
            int m = l+(h-l)/2;
            if(hp[m][0]<val){
                h = m;
            }
            else{
                l = m+1;
            }
        }
        return l;
    };
    function<int(int)> binw=[&](int val){
        int l = 0;
        int h = n;
        while(l<h){
            int m = l+(h-l)/2;
            if(wp[m][0]<val){
                h = m;
            }
            else{
                l = m+1;
            }
        }
        return l;
    };
    rep(i,0,n){
        int a = req[i][0];
        int b = req[i][1];
        int x = binh(a);
        if(x!=n){
            if(smhp[x].ff<b){
                cout<<smhp[x].ss<<" ";
                continue;
            }
        }
        x = binw(a);
        if(x!=n){
            if(smwp[x].ff<b){
                cout<<smwp[x].ss<<" ";
                continue;
            }
        }
        cout<<-1<<" ";
    }
}

    
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);  
    #endif
    */
    int test;
    cin>>test;    
    //test=1;
    //sieve();
    //int cse=1;
    while(test--){
       // cout<<"Case #"<<cse<<": ";
        solve();
        cout<<endl;
        //cse++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}