#include<iostream>
#include <map>
#include<vector>
using namespace std;


#include "partition.h"
std::vector<int> solve(std::vector<int> A) {
    vector<bool> used(A.size());
    map<int, bool> cnt;
    vector<int> res;
    for (int i = 0; i < A.size(); i++) {
        if (!cnt[A[i]]) {
            used[i] = true;
            res.push_back(i);
        }
        cnt[A[i]] = !cnt[A[i]];
    }
    for (int i = 0; i < A.size(); i++) {
        if (!used[i]) res.push_back(i);
    }
    return res;
}


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

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