#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second

extern vector<ll> solve(vector<ll> A) {

    map<ll,ll> mp;
    map<ll, bool> np;

    vector <ll> x;
    vector <ll> y;
    for (ll i=0; i<A.size(); i++) {
        mp[A[i]]++;
        np[i]=false;
        if (mp[A[i]]%2==1) {
            x.push_back(A[i]);
            y.push_back(i);
            np[i]=true;
        }
    }
    for (ll i=0; i<A.size(); i++) {
        if (np[i]==false) y.push_back(i);
    }

    return y;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t ;
    for (ll test=1; test<=t; test++) {
        ll n;
        cin >> n ;
        vector <ll> a(n);
        for (ll i=0; i<n; i++) {
            cin >> a[i] ;
        }

        for (auto ind : solve(a)) {
            cout << ind << " ";
        }
        cout << endl ;
    }
    cout << endl ;
    return 0;
}