#include <bits/stdc++.h>

#define pb push_back

using namespace std;
const int N = 2e6 + 5;

bool taken[N];

vector<int> solve(vector<int> a) {
    vector<int> ans;

    int n = a.size();

    map<int, bool> ap;
    for(int i=0; i<n; i++) {
        if(!ap[a[i]])
            ans.pb(i), taken[i] = 1;
        ap[a[i]] ^= 1;
    } 
    for(int i=0; i<n; i++)
        if(!taken[i])
            ans.pb(i);

    return ans;
}

#ifndef EVAL
int32_t main() {
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
    cin.tie(nullptr)->sync_with_stdio(0);

    int tt;
    cin >> tt;
    while(tt--) {
        vector<int> a;
        int n;
        cin >> n;
        for(int i=1; i<=n; i++) {
            int x;
            cin >> x;
            a.pb(x);
        }

        vector<int> res = solve(a);
        for(auto x : res)
            cout << x << ' ';
        cout << '\n';
    }
    return 0;
}
#endif