#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
#define shaman ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int h[200005],w[200005];
inline bool cmp(int a,int b){
    return h[a]<h[b];
}
inline bool cmp2(int a,int b){
    return w[a]<w[b];
}
signed main(){shaman
    int t,n;
    cin >> t;
    while(t--){
        cin >> n;
        vector <pii> v;
        vector <int> a(n),b(n),ans(n,-87);
        for(int i=0;i<n;i++) {
            cin >> h[i] >> w[i];
            a[i]=i;
            b[i]=i;
        }
        sort(a.begin(),a.end(),cmp);
        int pos=0,mn=2e9,id;
        for(int i=0;i<n;i++){
            while(pos<n&&h[a[pos]]<h[a[i]]){
                if(mn>w[a[pos]]){
                    mn=w[a[pos]];
                    id=a[pos];
                }
                pos++;
            }
            if(mn<w[a[i]]) ans[a[i]]=id;
        }
        sort(b.begin(),b.end(),cmp2);
        pos=0,mn=2e9;
        for(int i=0;i<n;i++){
            while(pos<n&&h[a[pos]]<w[b[i]]){
                if(mn>w[a[pos]]){
                    mn=w[a[pos]];
                    id=a[pos];
                }
                pos++;
            }
            if(mn<h[b[i]]) ans[b[i]]=id;
        }
        for(int i=0;i<n;i++){
            if(ans[i]<0)
                cout << -1 << " ";
            else cout << ans[i]+1 << " ";
        }
        cout << "\n";
    }
}
