#include<iostream>
using namespace std;
const int N = 500005;
int t,n;
int a[N];
bool b[N];
int main(){
cin >> t;
while(t--){
cin >> n;
for(int i = 0; i < N; i++){
b[i] = false;
}
for(int i = 1; i <= n; i++){
cin >> a[i];
if(b[a[i]] == false){
cout << a[i] << " ";
b[a[i]] = true;
}
}
cout << endl;
}
return 0;
}