#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node
{
int data;
struct node *next;
};
int main()
{
int n, m, i, j;
struct node *p, *q, *head, *t;
scanf("%d",&m);
for(j = 0; j < m; j++)
{
head = (struct node *)malloc(sizeof(struct node));
head -> next = NULL;
t = head;
scanf("%d",&n);
for(i =0 ; i < n; i++)
{
p = (struct node*)malloc(sizeof(struct node));
scanf("%d",&p -> data);
p -> next = NULL;
t -> next = p;
t = p;
}
t = head -> next;
q = head -> next;
for(i = 0 ; i < n -1; i++)
{
while(q -> next)
{
if(q -> next -> data == t ->data)
{
q -> next = q ->next -> next;
n--;
}
else
q = q -> next;
}
t= t -> next;
q = t;
}
t = head -> next;
for(i =0 ; i < n; i++)
{
printf("%d",t ->data);
if(t -> next != NULL)
printf(" ");
else
printf("\n");
t =t -> next;
}
}
return 0;
}