#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,x,n) for(int i=x;i<=n;i++)
#define all(c) c.begin(),c.end()
#define cin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define int int64_t
#define pi pair<int,int>
const int Nmax=1e6;
const int mod=1000000007;
vector<int>prime;
int is_power_of_two(int a){
    return a && (!(a&(a-1)));
}
int isperfectsquare(int a){
    double b=sqrt(a);
    return (b-ceil(b)==0);
}
int pow(int a,int b,int m){
    a=a%m;
    int res=1;
    while(b>0){
        if(b&1){
            res=res * a%m;
        }
        a=a * a %m;
        b=b/2;
    }
return res;
}
void seive(int n){
    bool isprime[n];
    memset(isprime,true,sizeof(isprime));
    prime.push_back(2);
    for(int i=3;i<=sqrt(n);i+=2){
        if(isprime[i]){
            for(int j=i*i;j<=n;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=3;i<=n;i+=2){
        if(isprime[i]){
            prime.push_back(i);
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,wt,ht;
        cin>>n;
        vector<pair<pi,int>>wtht;
        for(int i=0;i<n;i++){
            cin>>wt>>ht;
            wtht.push_back({{wt,-ht},i+1});
            wtht.push_back({{ht,-wt},i+1});
        }
        vector<int>index(n+1,-1);
        sort(all(wtht));
        // f(i,0,2*n-1){
        //     cout<<wtht[i].first.first<<" "<<wtht[i].first.second<<" "<<wtht[i].second<<endl;
        // }
        int minindex=-1;
        int minht=INT_MAX;
        f(i,0,2*n-1){
            int height=-wtht[i].first.second;
            int ind=wtht[i].second;
            if(height>minht){
                index[ind]=minindex;
            }
            else if(height<minht){
                minht=height;
                minindex=ind;
            }
        }
        f(i,1,n){
            cout<<index[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}