#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

namespace Solve
{
    template<typename T>
    void read(T& x)
    {
        x = 0;
        T s = 1;
        char c;
        do c = getchar(); while (c != '-' && (c < '0' || c > '9'));
        if (c == '-') {
            s = -1;
            c = getchar();
        }
        while('0' <= c && c <= '9') {
            x = x * 10 + c - '0';
            c = getchar();
        }
        x *= s;
    }
    typedef long long LL;

    const int MAXN = 200000 + 10;
    struct Item
    {
        int id;
        int w;
        int h;
    };
    bool cmp(const Item& A, const Item& B)
    {
        return A.w < B.w || (A.w == B.w && A.h < B.h);
    }

    int n;
    Item data[MAXN];
    int ans[MAXN];
    int minh[MAXN], minh_id[MAXN];

    void solve(int kase)
    {
        cin >> n;
        for (int i = 1; i <= n; i ++) {
            cin >> data[i].h >> data[i].w;
            data[i].id = i;
        }
        sort(data+1, data+1+n, cmp);

        minh[1] = data[1].h;
        minh_id[1] = data[1].id;
        for (int i = 2; i <= n; i ++) {
            if (data[i].h < minh[i-1]) {
                minh[i] = data[i].h;
                minh_id[i] = data[i].id;
            } else {
                minh[i] = minh[i-1];
                minh_id[i] = minh_id[i-1];
            }
        }

        for (int i = 1; i <= n; i ++) {
            ans[data[i].id] = -1;
            {
                int l = 0, r = n, mid;
                while (l < r) {
                    mid = (l + r) / 2 + 1;
                    if (data[mid].w < data[i].w) l = mid;
                    else r = mid - 1;
                }
                int pos = l;
                if (pos >= 1 && minh[pos] < data[i].h) {
                    ans[data[i].id] = minh_id[pos];
                }
            }
            {
                int l = 0, r = n, mid;
                while (l < r) {
                    mid = (l + r) / 2 + 1;
                    if (data[mid].w < data[i].h) l = mid;
                    else r = mid - 1;
                }
                int pos = l;
                if (pos >= 1 && minh[pos] < data[i].w) {
                    ans[data[i].id] = minh_id[pos];
                }
            }
        }

        for (int i = 1; i <= n; i ++) {
            cout << ans[i] << " ";
        }
        cout << endl;
    }
}

int main()
{
    int T;
    scanf("%d", &T);
    for(int kase = 1; kase <= T; kase ++)
        Solve::solve(kase);
    return 0;
}
