#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<map>
#define maxn 10000000
#define mod 23333
#define base 233333
using namespace std;
vector<int>link[mod + 1];
long long shu[maxn],ashu[maxn];
long long n, m;
long long get(int x) {
return (x % base + base) % mod;
}
bool tget(int x) {
for (int j = 0; j < link[get(x)].size(); ++j) {
//cout << " " << link[get(x)][j] << " " << x << endl;
if (link[get(x)][j] == x) {
return false;
}
}
return true;
}
int main(){
cin >> n;
while (n--) {
int po = 0;
memset(shu, 0, sizeof(shu));
memset(ashu, 0, sizeof(ashu));
memset(link, 0, sizeof(link));
cin >> m;
for (int i = 0; i < m; ++i) {
cin >> shu[i];
if (tget(shu[i]) ){
cout << shu[i]<<" ";
ashu[po++] = shu[i];
link[get(shu[i])].push_back(shu[i]);
}
}
cout << endl;
}
return 0;
}