#include <ctype.h>
#include <stdio.h>
#include <string.h>
#define RN 50005
#define HASH 3233323
typedef struct
{
int nxt;
int val;
char tag;
}
HNode;
#define IO 10000
char _ibuf[IO] , _obuf[IO];
char *_i = _ibuf, *_o = _obuf;
void initIO(void)
{
fread(_ibuf, sizeof(char), IO, stdin);
}
void endIO(void)
{
fwrite(_obuf, sizeof(char), _o - _obuf, stdout);
}
static inline char getch(void)
{
if (_i == _ibuf + IO)
{
memset(_ibuf, 0, sizeof(_ibuf));
fread(_ibuf, sizeof(char), IO, stdin);
_i = _ibuf;
}
return *_i++;
}
static inline void putch(char ch)
{
if (_o == _obuf + IO)
{
fwrite(_obuf, sizeof(char), IO, stdout);
_o = _obuf;
}
*_o++ = ch;
}
int getint(void)
{
int num = 0, fac = 1;
char ch = getch();
while (!isdigit(ch))
{
if (ch == '-')
fac = -1;
ch = getch();
}
while (isdigit(ch))
{
num = num * 10 + ch - '0';
ch = getch();
}
return num * fac;
}
void putint(int val)
{
if (val < 0)
{
val = -val;
putch('-');
}
if (val >= 10)
putint(val / 10);
putch(val % 10 + '0');
}
HNode node[RN];
unsigned short head[HASH];
int main(void)
{
initIO();
int t = getint();
while (t--)
{
int n = getint();
for (int i = 1; i <= n; i++)
{
int v = getint(), h = head[(unsigned) v % HASH];
if (!h)
{
node[i].val = v;
head[(unsigned) v % HASH] = i;
}
else for (int j = h; j; j = node[j].nxt)
{
if (v == node[j].val)
{
node[i].tag = 1;
break;
}
else if (!node[j].nxt)
{
node[i].val = v;
node[j].nxt = i;
break;
}
}
}
for (int i = 1; i <= n; i++)
{
if (!node[i].tag)
putint(node[i].val), putch(' ');
}
putch('\n');
memset(head, 0, sizeof(head));
memset(node, 0, sizeof(node));
}
endIO();
return 0;
}