#include <stdio.h>
#include <stdlib.h>
struct node
{
int a;
struct node *next;
};
int main()
{
struct node *p, *q, *head, *tail;
int n, i, m, k, b;
scanf("%d", &m);
while(m--)//建立链表,并输入第一个值
{
scanf("%d", &n);
head = (struct node *)malloc(sizeof(struct node));
head->next = NULL;
q = head;
p = (struct node *)malloc(sizeof(struct node));
scanf("%d", &p->a);
p->next = NULL;
q->next = p;
q = p;
n--;
while(n--)//输入值,判断是否重复
{
int t = 1;
tail = head;
p = (struct node *)malloc(sizeof(struct node));//不能少
scanf("%d", &k);
while(tail->next!=NULL)
{
tail = tail->next;
if(tail->a == k)//重复退出
{
t = 0;
break;
}
}
if(t)//不重复指向下一个
{
p->a = k;
p->next = NULL;
q->next = p;
q = p;
}
}
p = head;
while(p->next!=NULL)//输出链表
{
p = p->next;
printf("%d ", p->a);
}
printf("\n");
}
}