#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define all(v) begin(v),end(v)
#define pb push_back
#define fr first
#define sc second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
const int M = 1e9+7;
const int N = 1e6+5;
ll power(ll a, ll n) { 
ll res = 1; 
while (n) { 
if (n % 2) {res = (res * a) % M;} 
n >>= 1; a = (a * a) % M;} 
return res;
}

int main(){
	fast;
	int test; cin>>test;
	while(test--){
		int n;
		cin>>n;
		vector<pair<pair<int,int>,int>> vp;
		for(int i=0;i<n;i++){
			int h,w;
			cin>>h>>w;
			vp.pb({{w,-h},i});
			vp.pb({{h,-w},i});
		}
		sort(all(vp));
		int minh = INT_MAX;
		int ele = -1;
		vector<int> ans(n,-2);
		for(auto t:vp){
			int h = -t.fr.sc;
			int ind = t.sc;
			if(h>minh){
				ans[ind] = ele;
			}
			else if(h<minh){
				minh = h;
				ele = ind;
			}
		}
		rep(i,0,n){
			cout<<ans[i]+1<<" ";
		}
		cout<<endl;
	}
	return 0;
}


