#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int mxN = 2e5, mod = 1e9+7;
const int INF = 1e18;

int32_t main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t;
    cin>>t;
    while(t--)
    { 
       int n;
       cin>>n;
       vector<vector<int>>arr;
       for(int i = 0;i<n;i++)
       {
            int x,y;
            cin>>x>>y;
            arr.push_back({x,-y,i});
            arr.push_back({y,-x,i});
       }
       int h1 = INF;
       sort(arr.begin(),arr.end());
       int idx = -1;
       vector<int>ans(n,-2);
       for(auto it : arr)
       {
            int h = it[0];
            int w = -it[1];
            int id = it[2];
            if(h1 < w)
            {
                 ans[id] = idx;
            }
            if(w < h1)
            {
                 idx = id;
                 h1 = w;
            }
       }
       for(int i = 0;i<n;i++)
       {
            cout<<ans[i]+1<<" ";
       }
       cout<<"\n";
    }
    return 0;
}