#include<bits/stdc++.h>
using namespace std;
int t,n,a[500001],b[500001],c[500001],l;
inline long long read(){
long long a=0,fh=1;char c=getchar();
while(c>'9'||c<'0'){if(c=='-')fh=-1;c=getchar();}
while('0'<=c&&c<='9'){
a=a*10ll+c-48ll;
c=getchar();
}
return a*fh;
}
int main(){
ios::sync_with_stdio(false);
t=read();
for(int i=1;i<=t;i++){
n=read(),l=0;
memset(b,0,sizeof(b));
memset(c,0,sizeof(b));
for(int j=1;j<=n;j++){
a[i]=read();
if(b[a[i]]==0)c[++l]=a[i],b[a[i]]=1;
}
for(int j=1;j<=l;j++)cout<<c[j]<<" ";
cout<<endl;
}
}