#include <bits/stdc++.h>
#include "partition.h"

using namespace std;

int n;

std::vector<int> solve(std::vector<int> A) {
    map<int, vector<int>> fr;
    n = (int)A.size();
    for (int i = 0; i < n; ++i)
        fr[A[i]].push_back(i);

    vector<int> p1;
    vector<int> p2;
    for (auto &[val, ap] : fr) {
        assert(ap.size() == 2);

        p1.push_back(ap[0]);
        p2.push_back(ap[1]);
    }

    vector<int> ans;
    for (auto &pos : p1)
        ans.push_back(pos);

    for (auto &pos : p2)
        ans.push_back(pos);

    return ans;
}

#ifndef EVAL
#include<iostream>
#include<vector>
using namespace std;
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