A permutation of length $n$ is a sequence of integers from $1$ to $n$ of length $n$ containing each number exactly once. For example, $[1]$, $[4, 3, 5, 1, 2]$, $[3, 2, 1]$ are permutations, and $[1, 1]$, $[0, 1]$, $[2, 2, 1, 4]$ are not.

There was a permutation $p[1 \dots n]$. It was merged with itself. In other words, let's take two instances of $p$ and insert elements of the second $p$ into the first maintaining relative order of elements. The result is a sequence of the length $2n$.

For example, if $p=[3, 1, 2]$ some possible results are: $[3, 1, 2, 3, 1, 2]$, $[3, 3, 1, 1, 2, 2]$, $[3, 1, 3, 1, 2, 2]$. The following sequences are not possible results of a merging: $[1, 3, 2, 1, 2, 3$], [$3, 1, 2, 3, 2, 1]$, $[3, 3, 1, 2, 2, 1]$.

For example, if $p=[2, 1]$ the possible results are: $[2, 2, 1, 1]$, $[2, 1, 2, 1]$. The following sequences are not possible results of a merging: $[1, 1, 2, 2$], [$2, 1, 1, 2]$, $[1, 2, 2, 1]$.

Your task is to restore the permutation $p$ by the given resulting sequence $a$. It is guaranteed that the answer exists and is unique.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 400$) — the number of test cases. Then $t$ test cases follow.

The first line of the test case contains one integer $n$ ($1 \le n \le 50$) — the length of permutation. The second line of the test case contains $2n$ integers $a_1, a_2, \dots, a_{2n}$ ($1 \le a_i \le n$), where $a_i$ is the $i$-th element of $a$. It is guaranteed that the array $a$ represents the result of merging of some permutation $p$ with the same permutation $p$.


-----Output-----

For each test case, print the answer: $n$ integers $p_1, p_2, \dots, p_n$ ($1 \le p_i \le n$), representing the initial permutation. It is guaranteed that the answer exists and is unique.


-----Example-----
Input
5
2
1 1 2 2
4
1 3 1 4 3 4 2 2
5
1 2 1 2 3 4 3 5 4 5
3
1 2 3 1 2 3
4
2 3 2 4 1 3 4 1

Output
1 2 
1 3 4 2 
1 2 3 4 5 
1 2 3 
2 3 4 1

Source: codeforces | Difficulty: EASY
Tags: Greedy algorithms


Solutions:
for i in range(int(input())):
	x = {}
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(2 * n):
		if l[i] in x:
			continue
		x[l[i]] = 1
	for i in x.keys():
		print(i, end=' ')


for i in range(int(input())):
	n = int(input())
	doubleP = list(map(int, input().split()))
	singleP = []
	for j in doubleP:
		inMyList = j in singleP
		if not inMyList:
			singleP.append(j)
	for j in singleP:
		print(j, end=' ')
	print()


from collections import Counter
for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = Counter(b)
	d = ''
	for i in c:
		d += str(i)
		d += ' '
	print(d)


s = int(input())
for i in range(s):
	n = int(input())
	ar = list(map(int, input().split()))
	t = []
	for j in ar:
		if j not in t:
			t.append(j)
	for i in t:
		print(i, end=' ')
	print()


t = int(input())
ans = [''] * t
for j in range(t):
	n = int(input())
	a = list(map(str, input().split()))
	b = []
	for i in range(2 * n):
		if a[i] not in b:
			ans[j] += a[i] + ' '
			b.append(a[i])
for i in ans:
	print(i)


def solve():
	n = int(input())
	(*p,) = map(int, input().split())
	used = set()
	ans = []
	for pi in p:
		if pi not in used:
			ans.append(pi)
			used.add(pi)
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in range(2 * n):
		if a[i] not in ans:
			ans.append(a[i])
			print(a[i], end=' ')
	print('')


count = int(input())
for _ in range(count):
	l = int(input())
	ar = list(map(int, input().split()))
	print(*sorted(set(ar), key=ar.index))


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	al = list(dict.fromkeys(arr).keys())
	ans = ' '.join(map(str, al))
	print(ans)


import math
import sys
from sys import *
from bisect import insort
import heapq
import collections
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def isPanagram(s):
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for char in alphabet:
		if char not in s.lower():
			return False
	return True

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def remove_duplicate(list1):
	final_list = []
	for i in list1:
		if i not in final_list:
			final_list.append(i)
	return final_list % mod

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	ar = []
	for i in range(len(arr)):
		if arr[i] not in ar:
			ar.append(arr[i])
	return ' '.join(map(str, ar))
t = int(stdin.readline())
for i in range(t):
	result = solve()
	stdout.write(str(result) + '\n')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	seen = set()
	out = []
	for x in a:
		if x in seen:
			continue
		seen.add(x)
		out.append(x)
	print(*out)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	s = []
	for i in l:
		if i not in s:
			s.append(i)
	print(' '.join((str(i) for i in s)))


def main():
	for _ in range(int(input())):
		s = int(input())
		l = [int(i) for i in input().split()]
		k = []
		[k.append(i) for i in l if i not in k]
		print(*k)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	s = set()
	for x in a:
		if x in s:
			continue
		s.add(x)
		p.append(x)
	print(*p)


t = int(input())
for i in range(t):
	n = int(input())
	res = []
	govno = [int(i) for i in input().split()]
	for i in govno:
		if i not in res:
			res.append(i)
	for i in res:
		print(i, end=' ')
	print()


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	p = list(map(int, sys.stdin.readline().split()))
	table = [0] * (len(p) + 1)
	res = []
	for i in range(len(p)):
		if table[p[i]] == 1:
			res.append(p[i])
		else:
			table[p[i]] += 1
	for i in range(n):
		if i == n - 1:
			print(res[i])
		else:
			print(res[i], end=' ')


n = int(input())
tcs = []
for i in range(n):
	input()
	tcs.append([int(i) for i in input().split()])
for tc in tcs:
	original = []
	for i in tc:
		if i not in original:
			original.append(i)
	print(*original)


for _ in range(int(input())):
	n = int(input())
	s = set()
	val = [int(i) for i in input().split()]
	for v in val:
		if v not in s:
			print(v, end=' ')
			s.add(v)
	print()


t = int(input())
for j in range(t):
	n = int(input())
	L = map(int, input().split())
	L = list(L)
	A = []
	for i in L:
		if i not in A:
			A = A + [i]
	for i in A:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	val = []
	for j in range(len(a)):
		if a[j] in val:
			ans.append(a[j])
		else:
			val.append(a[j])
	print(*ans, sep=' ')


import sys
input = sys.stdin.buffer.readline
a = int(input())
for x in range(a):
	b = int(input())
	n = [1 for y in range(b)]
	c = list(map(int, input().split()))
	for y in c:
		if n[y - 1] == 1:
			print(y, end=' ')
			n[y - 1] = 0
			b -= 1
		if b == 0:
			print()
			break


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n1 = int(z())
for _ in range(n1):
	n = int(z())
	arr = zzz()
	ans = []
	for i in arr:
		if i not in ans:
			ans.append(i)
	print(*ans)


from collections import defaultdict
for _ in range(int(input())):
	hash_map = defaultdict(int)
	n = input()
	seq = ''
	for number in input().split():
		if hash_map[number] == 0:
			seq += number + ' '
			hash_map[number] = 1
	print(seq.strip())


for _ in range(int(input())):
	n = int(input())
	s = []
	l = list(map(int, input().split()))
	for i in range(len(l)):
		if l[i] not in s:
			s.append(l[i])
	else:
		print(*s)


n = int(input())
for i in range(n):
	l = input()
	ans = list()
	ans_set = set()
	array = map(int, input().split())
	for k in array:
		if k not in ans_set:
			ans_set.add(k)
			ans.append(k)
	print(*ans)


import sys, collections, math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	n = int(input())
	arr = get_array()
	d = {}
	lst = []
	for i in arr:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in d.keys():
		lst.append(i)
	print(*lst)


def perm():
	tc = int(input())
	for _ in range(tc):
		n = int(input())
		a = [int(x) for x in input().split()]
		s = []
		for i in a:
			if i in s:
				continue
			else:
				s.append(i)
		for i in s:
			print(i, end=' ')
		print()
perm()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0] * (n + 1)
	r = []
	for i in range(2 * n):
		if d[a[i]] != 0:
			r.append(a[i])
			d[a[i]] = 1
		else:
			d[a[i]] = 1
	for i in range(n):
		print(r[i], end=' ')
	print()


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	l1 = {}
	for i in range(0, 2 * n):
		if l[i] not in l1:
			l1[l[i]] = 1
			print(l[i], end=' ')
	print()


for case in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	dict1 = {}
	for i in arr:
		if i in dict1:
			continue
		else:
			dict1[i] = 1
			print(i, end=' ')
	print(end='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	li1 = []
	for i in li:
		if i not in li1:
			li1.append(i)
	print(*li1)


def uni(ls1):
	unique_list = []
	for x in ls1:
		if x not in unique_list:
			unique_list.append(x)
	print(*unique_list)
t = int(input())
for i in range(0, t):
	n = int(input())
	ls1 = list(map(int, input().split()))[:n * 2]
	uni(ls1)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	myset = set()
	sol = []
	for item in lst:
		if item not in myset:
			myset.add(item)
			sol.append(item)
	for item in sol:
		print(item, end=' ')
	print()


for _ in range(int(input())):
	a = []
	j = 0
	n = int(input())
	for k in input().split():
		if len(a) == j or a[j] != k:
			a.append(k)
		else:
			j += 1
	print(' '.join((str(i) for i in a)))


def main():
	t = int(input())
	ans = []
	for i in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		perm = []
		visited = set()
		for j in arr:
			if j not in visited:
				perm.append(j)
				visited.add(j)
		ans.append(perm)
	for i in ans:
		for j in i:
			print(j, end=' ')
		print()
main()


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = [0] * (n + 1)
	x = []
	for i in range(2 * n):
		if d[l[i]] == 0:
			x.append(l[i])
			d[l[i]] += 1
	print(*x)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	z = list(set(l))
	c = []
	for i in z:
		c.append(l.index(i))
	c.sort()
	a = []
	for i in c:
		a.append(l[i])
	print(*a)


T = int(input())
for i in range(T):
	temp1 = int(input())
	temp = input()
	temp = temp.split()
	temp = list(dict.fromkeys(temp))
	series = ''
	for j in temp:
		series += ' ' + j
	print(series.lstrip())


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = Counter()
	for i in a:
		b[i] += 1
	c = []
	d = Counter()
	for i in a:
		if d[i] < b[i] // 2:
			c.append(i)
			d[i] += 1
	print(*c)

def main():
	for t in range(int(input())):
		solve()
main()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print(*dict.fromkeys(l))


for t in range(int(input())):
	n = int(input())
	vis = [0 for i in range(n)]
	ans = []
	arr = list(map(int, input().split()))
	for i in arr:
		if not vis[i - 1]:
			vis[i - 1] = 1
			ans.append(i)
	print(*ans)


t = int(input())
for q in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	used = []
	for i in range(2 * n):
		if a[i] not in used:
			used.append(a[i])
		else:
			continue
	for i in range(n):
		print(used[i], end=' ')
	print()


for i in range(int(input())):
	x = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	k = []
	for j in range(len(l)):
		if l[j] in s and l[j] not in k:
			k.append(l[j])
	print(*k)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	n = n * 2
	ans = []
	sets = set()
	for i in range(n):
		if arr[i] not in sets:
			ans.append(arr[i])
			sets.add(arr[i])
	print(*ans)


t = int(input())
for i in range(t):
	t = int(input())
	a = list(map(int, input().split()))
	b = []
	for j in a:
		if j not in b:
			b.append(j)
	for j in range(len(b)):
		print(b[j], end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = []
	for i in range(2 * n):
		if l1[i] not in l2:
			l2.append(l1[i])
			print(l1[i], end=' ')
	print('\n')


try:
	from collections import Counter
	t = int(input())
	while t != 0:
		n = int(input())
		arr = list(map(int, input().split()))
		count_num = Counter(arr)
		ss = count_num.most_common()
		for i in range(len(ss)):
			print(ss[i][0], end=' ')
		print()
		t = t - 1
except EOFError:
	print(' ')


t = int(input())
while t > 0:
	size = int(input())
	inp = list(map(int, input().split()))
	tempo = [0]
	for i in range(size):
		tempo.append(0)
	ans = []
	for i in range(2 * size):
		if tempo[inp[i]] == 0:
			ans.append(inp[i])
			tempo[inp[i]] = 1
	for i in range(size):
		print(ans[i], end=' ')
	print()
	t -= 1


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()

def primeFactor(N):
	(i, n) = (2, N)
	ret = {}
	(d, sq) = (2, 99)
	while i <= sq:
		k = 0
		while n % i == 0:
			(n, k, ret[i]) = (n // i, k + 1, k + 1)
		if k > 0 or i == 97:
			sq = int(n ** (1 / 2) + 0.5)
		if i < 4:
			i = i * 2 - 1
		else:
			(i, d) = (i + d, d ^ 6)
	if n > 1:
		ret[n] = 1
	return ret

def divisor(n):
	div = [1]
	for (i, j) in primeFactor(n).items():
		div = [i ** k * d for d in div for k in range(j + 1)]
	return div

def PrimeNumSet(N):
	M = int(N ** 0.5)
	seachList = [i for i in range(2, N + 1)]
	primes = []
	while seachList:
		if seachList[0] > M:
			break
		primes.append(seachList[0])
		tmp = seachList[0]
		seachList = [i for i in seachList if i % tmp != 0]
	return primes + seachList

def LCM(b, mo=10 ** 9 + 7):
	prs = PrimeNumSet(max(b))
	M = dict(zip(prs, [0] * len(prs)))
	for i in b:
		dc = primeFactor(i)
		for (j, k) in dc.items():
			M[j] = max(M[j], k)
	r = 1
	for (j, k) in M.items():
		if k != 0:
			r *= pow(j, k, mo)
			r %= mo
	return r
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	n = I()
	a = LI()
	ans = []
	v = [0] * n
	for i in range(2 * n):
		if v[a[i] - 1] == 0:
			v[a[i] - 1] = 1
			ans += (a[i],)
	print(*ans)


from collections import OrderedDict
for _ in range(int(input())):
	int(input())
	x = list(map(int, input().split()))
	print(*list(OrderedDict.fromkeys(x)))


def fast(arr):
	table = set([])
	result = []
	for num in arr:
		if num not in table:
			result.append(num)
			table.add(num)
	return result

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = [int(x) for x in input().split()]
		result = fast(arr)
		print(' '.join((str(x) for x in result)))
main()


t = int(input())
for i in range(t):
	a = int(input())
	n = list(map(int, input().split()))[:2 * a]
	d = list(dict.fromkeys(n))
	print(str(d)[1:-1].replace(',', ''))


for _ in range(int(input())):
	x = int(input())
	s = set()
	l = list(map(int, input().split()))
	ans = []
	for i in l:
		if i not in s:
			s.add(i)
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	dic = {}
	ans = []
	for i in range(len(A)):
		if A[i] not in dic:
			ans.append(A[i])
			dic[A[i]] = 1
	print(*ans)


for _ in range(int(input())):
	t = int(input())
	n = []
	l = list(map(int, input().split()))
	for i in range(len(l)):
		if n.count(l[i]) == 0:
			n.append(l[i])
		else:
			continue
	print(*n)


for _ in range(int(input())):
	n = range(int(input()))
	a = [int(_) for _ in input().split()]
	set_a = set()
	l_a = []
	for item in a:
		if item not in set_a:
			l_a.append(item)
			set_a.add(item)
	print(' '.join((str(_) for _ in l_a)))


import sys
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
from itertools import permutations

def solve():
	(n,) = I()
	p = I()
	ans = []
	s = set()
	for i in range(2 * n):
		if p[i] in s:
			continue
		ans.append(p[i])
		s.add(p[i])
	print(*ans)
(t,) = I()
while t:
	t -= 1
	solve()


t = int(input())
b = []
a = []
n = 0
c = 0
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	a.append(b)
for i in range(len(a)):
	for j in range(len(a[i]) - 1):
		for l in range(j + 1, len(a[i]) - 1):
			if a[i][j] == a[i][l]:
				a[i].pop(l)
	a[i].pop(len(a[i]) - 1)
	print(*a[i])


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	for e in range(n * 2):
		if l[e] not in ans:
			ans.append(l[e])
	ans = list(ans)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = []
	new = []
	for i in range(2 * n):
		if a[i] not in new:
			new.append(a[i])
	print(*new)


for i in range(int(input())):
	n = int(input())
	p = list(input().split())
	saida = []
	for i in range(len(p)):
		if int(p[i]) not in saida:
			saida.append(int(p[i]))
			if len(saida) == n:
				break
	print(*saida, sep=' ')


t = int(input())
for t1 in range(t):
	n = int(input())
	a = [int(n1) for n1 in input().split()]
	b = []
	count = 0
	while count < len(a):
		if a[count] in b:
			pass
		else:
			b.append(a[count])
		count = count + 1
	print(*b)


n = int(input())
l = []
for _ in range(n):
	l.append([int(input()), list(map(int, input().split(' ')))])
for c in l:
	a = []
	for i in c[1]:
		if i not in a:
			a.append(i)
	print(' '.join(list(map(str, a))))


t = int(input())
for _ in range(t):
	k = int(input())
	n = list(map(int, input().split(' ')))
	m = [[__ + 1, 0] for __ in range(k)]
	for (i, j) in enumerate(n):
		m[j - 1][1] += 2 * k - i
	res = sorted(m, key=lambda x: x[1], reverse=True)
	for i in res:
		print(i[0], end=' ')
	print()


t = int(input())
for k in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	c = [False] * (2 * n + 2)
	result = []
	for i in range(2 * n):
		if not c[a[i]]:
			c[a[i]] = True
			result.append(a[i])
	print(*result)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	d = defaultdict(int)
	ans = []
	for i in p:
		if d[i] == 0:
			ans.append(i)
		d[i] += 1
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = set()
	out = []
	for i in arr:
		if i not in s:
			out.append(i)
			s.add(i)
	print(*out)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	k = {}
	for j in range(2 * n):
		if a[j] not in k:
			k[a[j]] = 0
	b = []
	for m in k.keys():
		b.append(m)
	print(*b, sep=' ')


total = int(input())
for _ in range(total):
	length_permuatation = input()
	b = list(map(int, input().strip().split(' ')))
	res = []
	for i in b:
		if i not in res:
			res.append(i)
	res = list(map(str, res))
	print(' '.join(res))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	ans = []
	for i in arr:
		if i not in ans:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


import math
import atexit
import io
import sys
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def array_to_string(a):
	s = ''
	for i in a:
		s += str(i) + ' '
	return s[:len(s) - 1]

def isPrime(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return 0
	return 1

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	checker = [0 for i in range(n)]
	b = [0 for i in range(n)]
	b[0] = a[0]
	b[-1] = a[-1]
	checker[b[0] - 1] = 1
	checker[b[-1] - 1] = 1
	c = 1
	for i in range(1, len(a) - 1):
		if checker[a[i] - 1] == 0:
			b[c] = a[i]
			checker[a[i] - 1] = 1
			c += 1
	print(array_to_string(b))


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		p = list(map(int, input().split()))
		l = set()
		for j in p:
			l.add(j)
		print(*l)
main()


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	for i in b:
		print(i, end=' ')


t = input()
t = int(t)
while t > 0:
	n = int(input())
	a = list(map(int, input().strip().split()))[:2 * n]
	s = {}
	ans = []
	for n in a:
		if n not in ans:
			ans.append(n)
	print(*ans)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	occ = [0] * (n + 1)
	for i in range(2 * n):
		if occ[a[i]] == 0:
			ans.append(a[i])
			occ[a[i]] = 1
	print(*ans, sep=' ')


def test():
	n = int(input())
	lst = map(int, input().split())
	ans = []
	for i in lst:
		if not i in ans:
			ans.append(i)
			if len(ans) == n:
				break
	print(*ans)
t = int(input())
for i in range(t):
	test()


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	nl = []
	for i in l:
		if i not in nl:
			nl.append(i)
	print(*nl)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	S = set()
	ans = []
	for a in A:
		if a not in S:
			S.add(a)
			ans.append(a)
	print(*ans)


import sys
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	first = set()
	ans = []
	for val in arr:
		if val not in first:
			ans.append(val)
			first.add(val)
	print(*ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = 0
	r = []
	r.append(a[0])
	for i in range(1, len(a)):
		if a[i] not in r:
			r.append(a[i])
	for i in r:
		print(i, end=' ')
	print('')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = []
	for i in l:
		if i in s:
			continue
		else:
			s.append(i)
	print(*s)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	x = {}
	for i in range(2 * n):
		if arr[i] not in x:
			x[arr[i]] = 1
			ans.append(arr[i])
	print(*ans)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	n = I()
	a = li()
	d = defaultdict(int)
	for i in a:
		if i not in d:
			print(i, end=' ')
			d[i] = 1
	print()
for _ in range(I()):
	solve()


for _ in range(int(input())):
	kkk = input()
	x = list(map(int, input().split()))
	l = {}
	a = []
	for i in x:
		if i not in l:
			l[i] = 1
		else:
			l[i] += 1
	print(*l.keys())


from collections import defaultdict, Counter
from math import log, ceil, floor

def solve():
	n = int(input())
	p = list(map(int, input().split()))
	l = set()
	x = []
	for i in p:
		if i not in l:
			x.append(i)
			l.add(i)
	print(*x)
t = 1
t = int(input())
for _ in range(t):
	solve()


t = int(input())
m = []
for i in range(t):
	n = int(input())
	m = list(map(int, input().split()))
	m = list(dict.fromkeys(m))
	for j in m:
		print(j, end=' ')
	print()


import sys
import collections

def input():
	return sys.stdin.readline().rstrip()

def split_input():
	return [int(i) for i in input().split()]
tests = int(input())
for _ in range(tests):
	n = int(input())
	a = split_input()
	s = set()
	p = []
	for i in range(len(a)):
		if a[i] not in s:
			s.add(a[i])
			p.append(a[i])
	print(*p, sep=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	x = [a[0]]
	for i in range(1, 2 * n):
		if a[i] not in x:
			x.append(a[i])
	print(*x)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	f = [0] * n
	for i in a:
		if f[i - 1] == 0:
			b.append(i)
			f[i - 1] = 1
	print(*b, sep=' ')


from sys import stdin
for case in range(int(stdin.readline())):
	n = int(stdin.readline())
	m = [int(x) for x in stdin.readline().split()]
	out = []
	found = set()
	for x in m:
		if not x in found:
			out.append(x)
			found.add(x)
	print(' '.join([str(x) for x in out]))


n = int(input())
for _ in range(n):
	l = int(input())
	x = list(map(int, input().split(' ')))
	a = []
	for i in x:
		if i not in a:
			a.append(i)
	print(*a)


from collections import defaultdict
from collections import Counter
from sys import setrecursionlimit as srl
srl(2 * 10 ** 6)

def solve(n, a):
	m = defaultdict(list)
	for (i, v) in enumerate(a):
		m[v].append(i)
	return list(m.keys())
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	print(*solve(n, a))
	t -= 1


def run():
	n = int(input())
	nums = [int(i) for i in input().split()]
	res = []
	for i in nums:
		if i not in res:
			res.append(i)
		else:
			pass
	print(' '.join((str(i) for i in res)))
for i in range(int(input())):
	run()


t = int(input())
teszt = []
hossz = []
for i in range(t):
	n = int(input())
	hossz.append(n)
	eset = [int(i) for i in input().split()]
	teszt.append(eset)
for i in range(t):
	h = 0
	z = 0
	m = []
	while h < hossz[i]:
		if teszt[i][z] not in m:
			m.append(teszt[i][z])
			h += 1
		z += 1
	print(*m)


for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	res = []
	for i in nums:
		if i not in res:
			res.append(i)
	print(*res)


t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	res = []
	for value in array:
		if value not in res:
			res.append(value)
		else:
			pass
	q = ' '.join((str(e) for e in res))
	print(q)


from collections import defaultdict
import math
inp = lambda : map(int, input().split())
num = lambda : int(input())
t = num()
for _ in range(t):
	n = num()
	a = list(inp())
	seen = [False] * (n + 1)
	for i in a:
		if not seen[i]:
			seen[i] = True
			print(i, end=' ')
	print()


t = int(input())
while t > 0:
	siz = int(input())
	per = list(map(int, input().split()))
	ans = []
	for i in per:
		if i not in ans:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	b = {}
	c = []
	for x in map(int, input().split()):
		if x not in b:
			c += (x,)
			b[x] = 1
	print(*c)


from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (fast, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer, end='\n'):
	stdout.write(str(answer) + end)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
num = int(z())
for _ in range(num):
	n = int(z())
	arr = zzz()
	res = []
	for i in arr:
		if i not in res:
			res.append(i)
	print(*res)


for _ in range(int(input())):
	n = int(input())
	p = [int(i) for i in input().split()]
	ans = []
	a = ''
	for i in range(2 * n):
		if p[i] not in ans:
			ans.append(p[i])
	for ele in ans:
		a = a + str(ele) + ' '
	print(a)


t = int(input())
ls = []
for j in range(t):
	l = int(input())
	p = []
	pt = ''
	s = list(map(int, input().rstrip().split()))
	for i in range(2 * l):
		if s[:i + 1].count(s[i]) == 1:
			p.append(s[i])
	for i in p:
		pt += str(i) + ' '
	pt.rstrip()
	ls.append(pt)
for i in ls:
	print(i)


from math import *
t = int(input())
while t > 0:
	n = int(input())
	freq = []
	a = [int(x) for x in input().split()]
	for i in range(n + 1):
		freq.append(0)
	ans = []
	for i in range(len(a)):
		if freq[a[i]] == 0:
			ans.append(a[i])
			freq[a[i]] += 1
	for i in range(len(ans)):
		print(ans[i], end=' ')
	print()
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	array = list(input().split(' '))
	ans = ''
	tab = [0 for i in range(n)]
	for i in range(2 * n):
		k = int(array[i])
		if tab[k - 1] == 0:
			ans = ans + array[i] + ' '
			tab[k - 1] = 1
		else:
			continue
	print(ans)


def f(arr):
	result = []
	for a in arr:
		if a not in result:
			result.append(a)
	return ''.join((str(e) + ' ' for e in result))
for _ in range(int(input())):
	int(input())
	print(f(list(map(int, input().split()))))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	used = []
	for x in arr:
		if x not in used:
			used.append(x)
	string = ''
	for x in used:
		string = string + str(x) + ' '
	print(string)


t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	arr = []
	for i in lis:
		if i not in arr:
			arr.append(i)
	print(*arr)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set()
	stack = []
	for i in l:
		if i not in s:
			stack.append(i)
			s.add(i)
	print(*stack)


t = int(input())
for _ in range(t):
	size = int(input())
	li = list(map(int, input().split()))
	seen = []
	for i in li:
		if i not in seen:
			seen.append(i)
	for i in seen:
		print(i, end=' ')


t = int(input())
for i in range(t):
	n = input()
	a = input().split(' ')
	a = list(map(int, a))
	r = list()
	for ele in a:
		if ele not in set(r):
			r.append(ele)
	print(' '.join(list(map(str, r))))


for t in range(int(input())):
	n = int(input())
	temp = []
	ar = [int(x) for x in input().split()]
	for i in ar:
		if i not in temp:
			temp.append(i)
	print(*temp)


t = int(input())
for tt in range(t):
	n = int(input())
	z = list(input().split())
	a = []
	a.append(z[0])
	for i in range(1, len(z)):
		c = 0
		for j in range(0, i):
			if z[j] == z[i]:
				c = 1
				break
		if c == 0:
			a.append(z[i])
	f = []
	for k in range(len(a)):
		if k == len(a) - 1:
			f.append(a[k])
		else:
			f.append(a[k])
			f.append(' ')
	p = ''
	pp = p.join(f)
	print(pp)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * 51
	for i in range(2 * n):
		b[a[i]] = b[a[i]] + 1
	for i in range(n + 1):
		b[i] = b[i] / 2
	ans = []
	for i in range(2 * n):
		if b[a[i]] != 0:
			ans.append(a[i])
			b[a[i]] = b[a[i]] - 1
	print(*ans)


for test in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	ans = []
	for i in p:
		if i not in ans:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


c = int(input())
for i in range(c):
	foo = input()
	l = [int(x) for x in input().split()]
	l2 = []
	for e in l:
		if str(e) not in l2:
			l2.append(str(e))
	ans = ' '.join(l2)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = a[::-1]
	ans = []
	for i in b:
		if i not in ans:
			ans.append(i)
	ans = ans[::-1]
	print(*ans, sep=' ')


for i in range(int(input())):
	counter = set()
	N = int(input())
	array = [int(x) for x in input().split()]
	tobeprinted = []
	for i in array:
		if i not in counter:
			counter.add(i)
			tobeprinted.append(i)
	print(*tobeprinted)


def solve(f):
	s = dict.fromkeys(f).keys()
	s = list(s)
	for i in range(0, len(s) - 1):
		print(s[i], end=' ')
	print(s[-1])

def main():
	for i in range(int(input())):
		n = int(input())
		solve([int(x) for x in input().split()])
main()


def check():
	n = int(input())
	a = [int(x) for x in input().split()]
	s = set()
	f = []
	for i in range(n * 2):
		if a[i] not in s:
			s.add(a[i])
			f.append(a[i])
	for i in f:
		print(i, end=' ')
	print()

def start():
	for t in range(int(input())):
		check()
start()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	check = [0] * n
	ans = []
	for i in range(len(l)):
		if check[l[i] - 1] == 0:
			check[l[i] - 1] = 1
			ans.append(l[i])
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = map(int, input().split())
	b = []
	for items in a:
		if items not in b:
			b.append(items)
	for items in b:
		print(items, end=' ')
	print()


t = int(input())
while t > 0:
	l = []
	l1 = []
	n = int(input())
	e = n * 2
	l = map(int, input().split())
	for j in l:
		if not j in l1:
			l1.append(j)
		else:
			continue
	print(*l1)
	t -= 1


t = int(input())
for ex in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	p = list()
	i = 0
	while len(p) < n and i < len(a):
		if a[i] in p:
			a.pop(i)
		else:
			p.append(a[i])
			i += 1
	ans = str(p[0])
	for i in range(1, len(p)):
		ans += ' ' + str(p[i])
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [True for _ in range(n + 1)]
	for i in a:
		if cnt[i]:
			print(i, end=' ')
			cnt[i] = False
	print()


a = int(input(''))
for i in range(0, a):
	p = int(input(''))
	b = list(map(int, input().split()))
	d = []
	for i in b:
		if i not in d:
			d.append(i)
	c = ''
	for j in d:
		c += str(j)
		c += ' '
	print(c)


num = int(input(''))
i = 0
while i < num:
	lens = int(input(''))
	arr = input('').split()
	num2 = len(arr)
	dic = {}
	for j in range(num2):
		for k in range(j + 1, num2):
			if arr[j] == arr[k]:
				dic[arr[j]] = k
				break
	i += 1
	sort_orders = sorted(dic.items(), key=lambda x: x[1])
	final = []
	for l in sort_orders:
		print(l[0])


n = int(input())
for _ in range(n):
	p = int(input())
	nums = list(map(int, input().split()))
	res = list()
	for n in nums:
		if n not in res:
			res.append(n)
	print(*res, end=' ')
	print('')


def ans():
	l = []
	for i in x:
		if i not in l:
			l.append(i)
	print(*l[:n])
t = int(input())
for i in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	ans()


n = int(input())
for i in range(n):
	list1 = []
	x = int(input())
	arr = [int(i) for i in input().split()]
	for j in arr:
		if j not in list1:
			list1.append(j)
	for k in list1:
		print(k, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	p = []
	p_set = set()
	for i in a:
		if len(p) > n:
			break
		if i in p_set:
			p.append(str(i))
		else:
			p_set.add(i)
	p = ' '.join(p)
	print(p)


for _ in range(int(input())):
	input()
	print(*set(map(int, input().split())))


for _ in range(int(input())):
	(n, a) = (int(input()), input().split())
	print(*[a[i] for i in range(n * 2) if a[i] not in a[:i]])


a = int(input())
for i in range(a):
	b = int(input())
	e = []
	c = list(map(int, input().split(' ')))
	for i in c:
		if i not in e:
			e.append(i)
		else:
			pass
	print(*e)


for t in range(int(input())):
	n = int(input())
	arr = list(map(str, input().split()))
	x = []
	for i in arr:
		if i not in x:
			x.append(str(i))
	print(' '.join(x))


from math import *
from copy import *
from string import *
from random import *
from sys import stdin, stdout
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math
import time
from queue import Queue

def seive(n):
	l = [True]
	l = l * (n + 1)
	for i in range(2, int(sqrt(n)) + 1):
		if l[i] == True:
			val = i * i
			while val < len(l):
				l[val] = False
				val += i
	prime = []
	for i in range(2, len(l)):
		if l[i] == True:
			prime.append(i)
	return prime

def dp(l, i, n, val, ans):
	if i >= n or val < 0:
		return 1000000
	elif val == 0:
		return 0
	else:
		if ans[i] == 1000000:
			ans[i] = min(min(1 + dp(l, i + 1, n, val - l[i], ans), 1 + dp(l, i, n, val - l[i], ans)), dp(l, i + 1, n, val, ans))
		return ans[i]
from queue import Queue

def factors(n):
	l = []
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def check1(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v -= 1

def check2(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v += 1

def up(n):
	j = n - 1
	while j > 0:
		if n % j == 0:
			break
		j -= 1
	return j

def fac(n):
	c = 1
	i = 1
	while i <= n:
		c *= i
		i += 1
	return c

def check_happy(n):
	ss = set()
	print(n)
	while n != 1:
		val = n
		s = 0
		print(val)
		while val != 0:
			s += (val % 10) ** 2
			val = val // 10
		print(val)
		print('hi')
		if val in ss:
			return False
		else:
			n = val
			ss.add(n)
	return True

def update(a, b):
	c = 1
	val = a
	while a < b:
		print(c, a)
		c += c
		a += a
	print(1)
	while a > b:
		print()
		a -= val
		c -= 1
	return c
import random as rand

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
from itertools import permutations
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	s = set()
	ans = []
	for i in l:
		if i not in s:
			s.add(i)
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	out = []
	for i in lst:
		if i not in out:
			out.append(i)
	for i in out:
		print(i, end=' ')
	print(' ')


x = int(input())
for i in range(x):
	y = int(input())
	l = []
	c = list(map(int, input().split()))
	for i in c:
		if i not in l:
			l += [i]
	print(*l)


def solution(a):
	result = []
	for elem in a:
		if not elem in result:
			result.append(elem)
		if len(result) == len(a) // 2:
			break
	return result
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	result = solution(a)
	for elem in result:
		print(elem, end=' ')


for _ in range(int(input())):
	num = 2 * int(input())
	a1 = list(map(int, input().split()))
	p = []
	for i in range(0, len(a1)):
		if a1[i] not in p:
			p.append(a1[i])
	for i in p:
		print(i, end=' ')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	res = []
	for i in range(len(l)):
		if l[i] not in res:
			res.append(l[i])
	print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split(' ')
	r = []
	for i in range(2 * n):
		if s[i] not in r:
			r.append(s[i])
	r = ' '.join(r)
	print(r)


n = int(input())
for i in range(n):
	inp = int(input())
	l = list(map(int, input().split()))
	p = []
	for i in l:
		if not i in p:
			p.append(i)
	for i in p:
		print(i, end=' ')


def main():
	t = int(input())
	for case in range(t):
		n = int(input())
		arr = [int(x) for x in input().split()]
		res = []
		s = set()
		i = 0
		while i < 2 * n:
			if arr[i] not in s:
				s.add(arr[i])
				res.append(arr[i])
			i += 1
		print(*res)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	i = 0
	while i < 2 * n:
		if a[i] not in p:
			p += [a[i]]
		i += 1
	for i in range(n):
		print(p[i], end=' ')
	print()


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = list(map(int, input().split()))
	used = [False for _ in range(n)]
	ans = []
	for a in alst[::-1]:
		if not used[a - 1]:
			used[a - 1] = True
			ans.append(a)
	print(*ans[::-1])
for _ in range(int(input())):
	main()


n = int(input())
for i in range(n):
	x = int(input())
	arr = list(map(int, input().split()))
	ans = []
	for j in arr:
		if j not in ans:
			ans.append(j)
			print(j, end=' ')
	print()


from sys import stdin

def readline():
	return stdin.readline()
tests = int(readline())

def solve(n, a):
	p = []
	for i in range(0, 2 * n):
		if a[i] not in p:
			p.append(a[i])
	return ' '.join((str(x) for x in p))
for t in range(0, tests):
	n = int(readline().rstrip('\n'))
	a = list(map(int, readline().split(' ')))
	print(solve(n, a))


a = int(input())
for _ in range(a):
	garbage = input()
	list1 = []
	array = list(map(int, input().split()))
	for i in array:
		if i not in list1:
			list1.append(i)
	print(*list1)


size = int(input())
tem = []
for i in range(size):
	x = int(input())
	ls = list(map(int, input().split()))
	for i in ls:
		if i in tem:
			pass
		else:
			tem.append(i)
	for i in range(x):
		print(tem[i], end=' ')
	print()
	tem.clear()


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	mapp = {}
	Str = []
	for i in arr:
		if i not in mapp:
			Str.append(i)
			mapp[i] = 1
	print(*Str, sep=' ')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for i in range(len(a)):
		if a[i] in p:
			continue
		p.append(a[i])
	for i in range(len(p)):
		print(p[i], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	x = [0 for i in range(n + 1)]
	Ans = []
	for i in range(2 * n):
		if x[A[i]] != 1:
			x[A[i]] += 1
			Ans.append(A[i])
	print(*Ans)


t = int(input())
while t != 0:
	n = int(input())
	p = []
	l = list(map(int, input().split()))
	for i in l:
		if i not in p:
			p.append(i)
	print(*p)
	t = t - 1


def rec(a, b):
	un = []
	for i in b:
		if i not in un:
			un.append(i)
	print(*un)
for i in range(int(input())):
	rec(int(input()), list(input().split()))


from collections import Counter
t_c = int(input())
while t_c != 0:
	n = int(input())
	li = list(map(int, input().split()))
	f_li = []
	for i in li:
		if i not in f_li:
			f_li.append(i)
	print(*f_li)
	t_c -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = set()
	ans = []
	for i in arr:
		if i not in s:
			s.add(i)
		else:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		A = list(map(int, input().split()))
		ans = []
		s = set()
		for i in range(2 * N):
			if A[i] not in s:
				s.add(A[i])
				ans.append(A[i])
		print(*ans)
main()


for _ in range(int(input())):
	n = int(input())
	list1 = list(map(int, input().split()))
	set1 = set()
	for i in list1:
		if i not in set1:
			print(i, end=' ')
			set1.add(i)


for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	stack = []
	for i in range(2 * N):
		if a[i] not in stack:
			stack.append(a[i])
	print(*stack)


no_of_test_cases = int(input())
for i in range(no_of_test_cases):
	n = int(input())
	temp = []
	res = ''
	data = list(map(int, input().split()))
	for element in data:
		if element not in temp:
			temp.append(element)
			res += str(element) + ' '
	print(str(res))


import math
T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a = set(a)
	print(*a)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(item) for item in input().split()]
	visited = [0] * (n + 1)
	ans = []
	for item in a:
		if visited[item] == 1:
			ans.append(item)
		else:
			visited[item] += 1
	print(*ans)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set()
	a = []
	for e in l:
		if e not in s:
			s.add(e)
			a.append(e)
	print(*a)


def solve():
	n = int(input())
	pp = list(map(int, input().split()))
	p = []
	e = set()
	for x in pp:
		if x not in e:
			p.append(x)
			e.add(x)
	print(*p)
for _ in range(int(input())):
	solve()


def test(n, s):
	was = []
	answer = []
	for i in s:
		if i not in was:
			answer.append(str(i))
			was.append(i)
	return answer
t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	print(' '.join(test(n, s)))


def restore_perm(n, p_m):
	is_traversed = [False] * n
	p = []
	for i in range(2 * n):
		if not is_traversed[p_m[i] - 1]:
			p.append(p_m[i])
			is_traversed[p_m[i] - 1] = True
	print(*p, sep=' ')
t = int(input())
for i in range(t):
	n = int(input())
	p_m = list(map(int, input().split()))
	restore_perm(n, p_m)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	for i in range(2 * n):
		a = arr[i]
		if a in ans:
			continue
		else:
			ans.append(a)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	c = 0
	p = []
	while c != n:
		for x in a:
			if x not in p:
				p.append(x)
				c += 1
				print(x, end=' ')


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	ans = []
	for i in lis:
		if i not in ans:
			ans.append(i)
		if len(ans) == n:
			break
	print(*ans)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	db = [0] * n
	c = 0
	res = []
	for i in range(2 * n):
		if c == n:
			break
		if db[arr[i] - 1] == 0:
			res.append(arr[i])
			db[arr[i] - 1] = 1
			c += 1
	print(*res)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i not in d:
			print(i, end=' ')
			d[i] = 1
	print()


for t in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	for i in range(1, n + 1):
		l.remove(i)
	for i in range(n):
		print(l[i], end=' ')
	print()


test = int(input())
for j in range(test):
	n = int(input())
	x = list(map(int, input().split()))
	y = list()
	for i in range(len(x)):
		if x[i] in y:
			continue
		y.append(x[i])
	for i in range(len(y)):
		if i != len(y) - 1:
			print(y[i], end=' ')
		else:
			print(y[i])


t = int(input())
for tt in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	foo = [-1] * (n + 1)
	ans = []
	for i in l:
		if foo[i] == -1:
			ans.append(str(i))
			foo[i] = 1
	print(' '.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	v = list(map(int, input().split()))
	tmp = []
	for i in v:
		if i not in tmp:
			tmp.append(i)
	for i in tmp:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(len(a)):
		j = i + 1
		while j < len(a):
			if a[j] == a[i]:
				a = a[:j] + a[j + 1:]
				break
			j += 1
	print(*a)


tharsh = int(input())
for i in range(tharsh):
	nharsh = int(input())
	lharsh = list(map(int, input().split()))
	harsh = {}
	for j in range(len(lharsh)):
		if lharsh[j] not in harsh:
			harsh[lharsh[j]] = 1
			print(lharsh[j], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	done = [0] * n
	perm = []
	for el in arr:
		if done[el - 1] == 0:
			perm.append(el)
			done[el - 1] = 1
	print(' '.join([str(x) for x in perm]))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = [False] * (n + 1)
	ans = []
	for i in l:
		if d[i] == False:
			ans.append(i)
			d[i] = True
	print(*ans, sep=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	di = {}
	ans = []
	for i in lis:
		if i not in di:
			di[i] = 1
			ans.append(i)
	print(*ans, sep=' ')


n = int(input())
for _ in range(n):
	x = int(input())
	z = []
	arr = list(map(int, input().split()))
	for i in range(2 * x):
		if arr[i] not in z:
			z.append(arr[i])
	print(*z)


t = int(input())
for x in range(t):
	n = int(input())
	permutation = str(input()).split()
	final_list = []
	for i in permutation:
		if i not in final_list:
			final_list.append(i)
	sep = ' '
	print(sep.join(final_list))


from sys import stdin
from collections import deque
input = stdin.readline

def getstr():
	return input()[:-1]

def getint():
	return int(input())

def getints():
	return list(map(int, input().split()))

def getint1():
	return list(map(lambda x: int(x) - 1, input().split()))

def solve():
	n = getint()
	x = getints()
	f = [False] * (n + 1)
	ans = []
	for i in x:
		if not f[i]:
			f[i] = True
			ans.append(i)
	print(' '.join(map(str, ans)))
for _ in range(getint()):
	solve()


for _ in range(int(input())):
	rn = int(input())
	Intarr = list(map(int, input().split()))
	Tlemp = []
	for i in range(2 * rn):
		if Intarr[i] not in Tlemp:
			Tlemp.append(Intarr[i])
	for i in range(rn):
		print(Tlemp[i], end=' ')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	for t in range(int(input())):
		n = int(input())
		l = [int(j) for j in input().split()]
		d = set()
		ans = []
		for i in range(2 * n):
			if l[i] not in d:
				d.add(l[i])
				ans.append(l[i])
		print(' '.join(map(str, ans)))
main()


for _ in range(int(input())):
	n = 2 * int(input())
	arr = list(map(int, input().split()))
	lis = []
	for i in range(0, len(arr)):
		if arr[i] not in lis:
			lis.append(arr[i])
	for i in lis:
		print(i, end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	li = []
	li.append(a[0])
	k = 0
	print(a[0], end=' ')
	for i in range(1, 2 * n):
		if a[i] != a[k] and a[i] not in li:
			print(a[i], end=' ')
			li.append(a[i])
		else:
			k += 1
	print()


t = int(input())
for ele in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr1 = []
	for x in arr:
		if x not in arr1:
			arr1.append(x)
	for x in arr1:
		print(x, end=' ')
	print()


for s in [*open(0)][2::2]:
	print(*dict.fromkeys(s.split()))


for _ in range(int(input())):
	k = []
	i = int(input())
	j = list(map(int, input().split()))
	for a in j:
		if a not in k:
			k.append(a)
			print(a, end=' ')
	print()


def Permutations(x, n):
	arr = []
	for i in x:
		if i not in arr:
			arr.append(i)
	print(*arr)
t = int(input())
for i in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	Permutations(x, n)


for i in range(int(input())):
	lenn = int(input())
	list1 = list(map(int, input().split()))
	output = ''
	helper = []
	for i in list1:
		if i not in helper:
			output += str(i) + ' '
			helper.append(i)
	print(output)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = set()
	ans = []
	for v in arr:
		if v not in s:
			ans.append(v)
			s.add(v)
	print(*ans)


for _ in range(int(input())):
	input()
	res = []
	for i in list(map(int, input().split())):
		if i not in res:
			res.append(i)
			print(i, end=' ')
	print()


def test(m, n):
	r = []
	for i in m:
		if str(i) not in r:
			r.append(str(i))
	print(' '.join(r))
t = int(input())
for i in range(t):
	n = int(input())
	m = list(map(int, input().split(' ')))
	test(m, n)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	for i in l:
		if i not in ans:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	f = [0] * (n + 1)
	l = list(map(int, input().split()))
	ans = []
	for i in l:
		if f[i] == 0:
			f[i] = 1
			ans.append(str(i))
	print(' '.join(ans))


from math import *
tests = int(input())
for t in range(tests):
	n = int(input())
	visited = [False] * (n + 1)
	a = list(map(int, input().split()))
	for i in range(2 * n):
		if not visited[a[i]]:
			print(a[i], end=' ')
			visited[a[i]] = True
	print('')


Test = int(input())
while Test > 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	print(*b)
	Test -= 1


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	s = set()
	for i in a:
		if i not in s:
			l.append(i)
			s.add(i)
	for i in l:
		print(i, end=' ')
	print()


def solve():
	t = int(input())
	for _ in range(t):
		n = int(input()) * 2
		m = input().split()
		s = set()
		ans = []
		for i in range(n):
			if m[i] not in s:
				ans.append(m[i])
			s.add(m[i])
		print(' '.join(ans))
solve()


a = int(input())
for i in range(a):
	b = int(input())
	l = list(map(int, input().split()))
	d = []
	for i in range(len(l)):
		if l[i] not in d:
			d.append(l[i])
	print(*d)


number_test = int(input())
lista_final = []
for test in range(number_test):
	initial_permuting = int(input())
	permuting = input()
	lista_intermedia = []
	permuting_list = [str(number) for number in permuting.split(' ')]
	for combination in permuting_list:
		if combination not in lista_intermedia:
			lista_intermedia.append(combination)
	lista_final.append(lista_intermedia)
for lista in lista_final:
	print(' '.join(lista))


t = int(input())
for tc in range(t):
	n = int(input())
	lst = input().split()
	ans = []
	ansl = 0
	for i in lst:
		if i not in ans:
			ans.append(i)
			if len(ans) >= n:
				break
	for i in ans:
		print(i, end=' ')
	print()


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	w = int(input())
	a = list(map(int, input().split()))
	q = []
	for i in a:
		if i not in q:
			q.append(i)
	print(*q)


for _ in range(int(input())):
	s = input()
	li = list(map(int, input().split()))
	mapping = set()
	out = []
	for i in li:
		if i not in mapping:
			out.append(i)
			mapping.add(i)
	print(' '.join(map(str, out)))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ans = set()
	for i in arr:
		if i not in ans:
			print(i, end=' ')
		ans.add(i)
	print()


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	seta = set()
	data = []
	for num in arr:
		if num in seta:
			data.append(num)
		else:
			seta.add(num)
	for num in data:
		print(num, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		if i not in b:
			b.append(i)
		if len(b) == n:
			print(*b)
			break


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	p = input().split()[::-1]
	listnum = tuple(set(p))
	for num in listnum:
		p.pop(p.index(num))
	p = p[::-1]
	ans.append(p)
for case in ans:
	print(' '.join(case).strip())


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	ans = []
	for j in range(2 * n):
		if str(arr[j]) not in ans:
			ans.append(str(arr[j]))
		if len(ans) == n:
			break
	print(' '.join(ans))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()][:2 * n]
	x = []
	for i in a:
		if i not in x:
			x.append(i)
			print(i, end=' ')
		if len(x) == n:
			break
	print('')


from collections import defaultdict
for _ in range(int(input())):
	nn = int(input())
	st = input()
	l = list(map(int, st.split()))
	s = defaultdict(int)
	for i in l:
		s[i] = 1
	print(*s.keys())


def ans(a, n):
	z = set()
	for x in a:
		if x not in z:
			print(x, end=' ')
			z.add(x)
	print()
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	ans(a, n)


i = int(input())
for _ in range(i):
	n = int(input())
	no = list(map(int, input().split()))
	j = []
	for k in range(len(no)):
		if no[k] not in j:
			j.append(no[k])
	for _ in j:
		if _ != j[-1]:
			print(_, end=' ')
		else:
			print(_)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a = list(set(arr))
	arr = arr[::-1]
	for i in range(len(a)):
		arr.remove(int(a[i]))
	arr = arr[::-1]
	print(*arr)


t = int(input())
for i in range(t):
	n = int(input())
	f = list(map(int, input().split()))
	f2 = []
	for j in range(2 * n):
		if f[j] not in f2:
			f2.append(f[j])
	print(*f2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a = list(dict.fromkeys(a))
	print(*a)


def sort():
	L = input('')
	p = input('')
	l = p.split(' ')
	a = l
	if len(a) == 1 or len(a) == 1:
		return None
	t = []
	for i in a:
		if str(i) not in t:
			t.append(str(i))
	print(' '.join(t))
a = int(input(' '))
for i in range(a):
	sort()


for i in range(int(input())):
	n = int(input())
	l = [int(num) for num in input().split()]
	a = [l[0]]
	for j in range(1, 2 * n):
		if l[j] not in a:
			a.append(l[j])
	print(*a)


import collections
for _ in range(int(input())):
	size = int(input())
	p = [int(x) for x in input().split()]
	seen = set()
	q = collections.deque()
	for e in p:
		if e in seen:
			continue
		q.append(str(e))
		seen.add(e)
	print(' '.join(q))


t = int(input())
for p in range(0, t):
	try:
		n = int(input())
		l = []
		x = list(map(int, input().split()))
		for i in range(0, len(x)):
			if str(x[i]) not in l:
				l.append(str(x[i]))
		print(' '.join(l))
	except Exception as e:
		pass


from collections import deque
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dq = deque()
	b = []
	for i in range(2 * n):
		if not dq:
			dq.append(a[i])
			b.append(a[i])
		elif a[i] == dq[0]:
			dq.popleft()
		else:
			dq.append(a[i])
			b.append(a[i])
	for i in b:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	x = [int(i) for i in input().split()]
	z = []
	for i in x:
		if i not in z:
			z.append(i)
	print(*z)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	freq = {}
	for i in l:
		if i in freq:
			freq[i] += 1
			a.append(i)
		else:
			freq[i] = 1
	print(*a)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dic = {}
	for item in a:
		if dic.get(item, 0) == 0:
			dic[item] = 1
	print(*dic.keys())


def f(arr):
	res = []
	for i in range(len(arr)):
		if not arr[i] in res:
			res.append(arr[i])
	return res
n = int(input())
for i in range(n):
	a = input()
	r = f(list(map(int, input().split())))
	for j in r:
		print(j, end=' ')


def solve():
	n = int(input())
	lst = list(map(int, input().split()))
	ans = [0 for i in range(n)]
	j = 0
	ann = []
	for i in range(len(lst)):
		if ans[lst[i] - 1] == 0:
			ans[lst[i] - 1] = 1
			ann.append(lst[i])
	print(*ann)
for i in range(int(input())):
	solve()


for _ in range(int(input())):
	found = [False] * int(input())
	for v in map(int, input().split()):
		if not found[v - 1]:
			print(v, end=' ')
			found[v - 1] = True
	print()


t = int(input())
for q in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	kk = 1
	c = 0
	s = set()
	for i in l:
		if i not in s:
			s.add(i)
			print(i, end=' ')
			c += 1
			if c == n:
				break
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	u = []
	for i in a:
		if i not in u:
			u.append(i)
			print(i, end=' ')


for _ in range(int(input())):
	n = int(input())
	a = [0] * n
	b = [int(x) for x in input().split()]
	for i in b:
		if a[i - 1] == 0:
			print(i, end=' ')
		a[i - 1] = 1
	print()


n = input()
for i in range(0, int(n)):
	l = int(input())
	lst = list(map(int, input().split()))
	res = []
	seen = []
	for k in lst:
		if k in seen:
			res.append(k)
		else:
			seen.append(k)
	print(*res)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = input().split()
	set_a = list(set(a))
	s = ''
	i = 0
	while len(set_a) != 0:
		if a[i] in set_a:
			s = s + a[i] + ' '
			set_a.remove(a[i])
		i = i + 1
	print(s)


t = int(input())
k = 0
for i in range(0, t):
	n = int(input())
	l = list(map(int, input().split()))
	p = [0]
	p[0] = l[0]
	j = 0
	while j <= len(l) - 1:
		if p.count(l[j]) == 0:
			p.append(l[j])
			del l[j]
			j -= 1
		j += 1
	for i in range(0, n):
		print(p[i], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	li = []
	for i in arr:
		if i in li:
			continue
		else:
			li.append(i)
	for i in li:
		print(i, end=' ')
	print()


t = int(input())
cases = []
for i in range(t):
	input()
	cases.append(input().strip().split())

def solve(case):
	a = []
	letters = set(case)
	for x in case:
		if x in letters:
			a.append(x)
			letters.remove(x)
		else:
			continue
	print(' '.join(a))
for case in cases:
	solve(case)


def find(l, li):
	li2 = []
	s = set()
	for i in li:
		if i not in s:
			li2.append(str(i))
		s.add(i)
	print(' '.join(li2))
n = int(input())
for i in range(0, n):
	l = int(input())
	li = list(map(int, input().split()))
	find(l, li)


m = int(input())
for j in range(m):
	arr = []
	n = int(input())
	l = list(map(int, input().split()))
	for i in range(n * 2):
		if l[i] not in arr:
			arr.append(l[i])
	print(*arr)


import math

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def bs(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return arr[mid]
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def swap(list, pos1, pos2):
	(list[pos1], list[pos2]) = (list[pos2], list[pos1])
	return list
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	j = 0
	for i in range(2 * n):
		if j < len(ans) and ans[j] == a[i]:
			j += 1
		else:
			ans.append(a[i])
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = list(set(a))
	q = []
	for i in a:
		if i not in q:
			q.append(i)
	print(*q)


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for i in range(n):
	m = inp()
	l = inlt()
	res = []
	for x in l:
		if x not in res:
			res.append(x)
	ans = ''
	for x in res:
		ans += str(x) + ' '
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			print(i, end=' ')
			b[i] = 0
	print()


import sys

def readStr():
	return sys.stdin.readline().rstrip()

def readInts():
	return list(map(int, readStr().split(' ')))

def main(n, a):
	p = list()
	s = set()
	for ai in a:
		if ai not in s:
			p.append(ai)
			s.add(ai)
	return p
(t,) = readInts()
for _ in range(t):
	(n,) = readInts()
	a = readInts()
	p = main(n, a)
	print(' '.join(map(str, p)))


for i in range(int(input())):
	a = int(input())
	answer = []
	b = list(map(str, input('').split()))
	for j in range(len(b)):
		if b[j] in answer:
			continue
		else:
			answer.append(b[j])
	print(' '.join(answer))


t = int(input())
while t:
	n = int(input())
	a = [int(x) for x in input().split()]
	flags = [0] * n
	res = []
	for num in a:
		if flags[num - 1] == 0:
			res.append(num)
			flags[num - 1] = 1
		if len(res) == n:
			break
	for num in res:
		print(str(num), end=' ')
	print('\n')
	t -= 1


import math
from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	ans = []
	for i in range(n * 2):
		if d[a[i]] == 0:
			ans.append(a[i])
			d[a[i]] = 1
	print(*ans)


t = int(input())
for _ in range(t):
	input()
	l = list(map(int, input().split()))
	d = {}
	p = []
	for x in l:
		if x in d:
			continue
		d[x] = 1
		p.append(x)
	print(' '.join(map(str, p)))


for _ in range(int(input())):
	n = int(input())
	List = list(map(int, input().split()))
	L = []
	for i in range(len(List)):
		if List[i] in L:
			List[i] = -1
		else:
			L.append(List[i])
	for i in L:
		print(i, end=' ')


t = int(input())
for x in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	vis = [0] * (len(arr) + 1)
	ans = []
	for i in arr:
		if vis[i] == 0:
			ans.append(i)
			vis[i] = 1
	for i in ans:
		print(i, end=' ')
	print()


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = [0] * n
	d = defaultdict(int)
	j = 0
	for i in range(2 * n):
		if d[a[i]] == 0:
			l[j] = a[i]
			j += 1
			d[a[i]] += 1
	print(' '.join((str(i) for i in l)))


from collections import Counter
t = int(input())
for i in range(t):
	n = int(input())
	l = list(input().split())
	res = Counter(l)
	for i in res:
		print(i, end=' ')
	print()


cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	p = []
	for i in a:
		if i not in d:
			p.append(i)
			d[i] = True
	print(*p)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for j in d.keys():
		print(j, end=' ')
	print()


def mi():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return input().split()
t = ii()
for _ in range(t):
	n = ii()
	a = li()
	b = [0 for i in range(n + 1)]
	for i in a:
		if b[i] == 0:
			b[i] = 1
			print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	hmap = {}
	for (i, c) in enumerate(arr):
		if c not in hmap:
			res.append(c)
			hmap[c] = True
	print(' '.join(list(map(str, res))))


for t in range(int(input())):
	n = 2 * int(input())
	a = list(map(int, input().split()))
	c = []
	b = []
	for i in range(n // 2):
		c.append(0)
	for j in range(n):
		if c[a[j] - 1] == 0:
			b.append(a[j])
			c[a[j] - 1] = 1
	for i in range(n // 2):
		print(b[i], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	was = [0 for _ in range(2 * n)]
	for j in range(len(a)):
		if not was[a[j]]:
			print(a[j], end=' ')
			was[a[j]] = 1
	print()


input1 = int(input())
while input1 > 0:
	len1 = input()
	list1 = [x for x in input().split()]
	list2 = []
	for i in list1:
		if i not in list2:
			list2.append(i)
	str1 = ''
	for i in list2:
		str1 += i + ' '
	print(str1)
	input1 -= 1


def f7(seq):
	seen = set()
	seen_add = seen.add
	return [x for x in seq if not (x in seen or seen_add(x))]
n = int(input())
for _ in range(n):
	input()
	print(*f7(map(int, input().split())))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lis = [0] * n
	ans = []
	for j in range(2 * n):
		if lis[arr[j] - 1] == 0:
			ans.append(arr[j])
			lis[arr[j] - 1] = 1
	print(' '.join((str(x) for x in ans)))


import sys
cin = lambda : sys.stdin.readline()
cout = lambda x: sys.stdout.write(x)
for T in range(int(cin())):
	n = cin()
	a = list(map(int, cin().split()))
	ans = []
	while a != []:
		t = a[0]
		a.remove(t)
		a.remove(t)
		ans.append(str(t))
	cout(' '.join(ans))
	cout('\n')


for _ in range(int(input())):
	n = int(input())
	inp = list(map(int, input().split()))
	nl = []
	for i in inp:
		if i not in nl:
			nl.append(i)
	print(*nl)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = set()
	ans = []
	for i in a:
		if i not in x:
			ans.append(i)
			x.add(i)
	print(*ans)


import sys
tests = int(sys.stdin.readline().split()[0])
for test in range(tests):
	n = int(sys.stdin.readline().split()[0])
	a = [int(i) for i in sys.stdin.readline().split()]
	print(*list(set(a)))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = Counter(l)
	print(*list(d.keys()))


for _ in range(int(input())):
	a = []
	n = int(input())
	s = [int(i) for i in input().split()]
	for i in s:
		if i not in a:
			a.append(i)
		else:
			continue
	print(*a)


T = int(input())
for t in range(T):
	n = int(input())
	l = list(map(int, input().rstrip().split(' ')))
	ans = []
	for i in l:
		if i not in ans:
			ans.append(i)
		if len(ans) == n:
			break
	for i in ans:
		print(i, end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in a:
		if str(i) not in l:
			l.append(str(i))
	print(' '.join(l).strip())


t = int(input())
for j in range(t):
	n = int(input())
	b = n * 2
	a = [0] * b
	a = list(map(int, input().split()))
	k = n + 1
	cnt = [0] * k
	output = ''
	for i in range(b):
		if cnt[a[i]] == 0:
			output += str(a[i]) + ' '
			cnt[a[i]] = 1
	print(output)


n = int(input())
a = []
b = 0
c = []
for i in range(n):
	m = int(input())
	l = list(map(int, input().split()))
	a.append(l)
for i in range(n):
	b = a[i]
	for j in b:
		if j not in c:
			c.append(j)
	s = list(map(str, c))
	print(' '.join(s))
	c.clear()


import sys
import math
from collections import defaultdict

def solve(test):
	n = int(input())
	a = list(map(int, input().split()))
	rec = set()
	ans = []
	for i in range(2 * n):
		if a[i] not in rec:
			rec.add(a[i])
			ans.append(str(a[i]))
	print(' '.join(ans))
test_cases = int(input())
for t in range(1, test_cases + 1):
	solve(t)


test_cases = int(input())
for i in range(test_cases):
	size = int(input())
	permutation = list(map(int, input().split()))
	restore_seq = []
	for i in permutation:
		if i not in restore_seq:
			restore_seq.append(i)
	print(' '.join([str(i) for i in restore_seq]))


def restore(arr):
	ans = []
	for i in arr:
		if i in ans:
			continue
		else:
			ans.append(i)
	for i in ans:
		print(i, '', end='')
	print()
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	restore(arr)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	p = []
	for i in arr:
		if i not in p:
			p.append(i)
	print(*p)


for _ in range(int(input())):
	n = int(input())
	nums = list(input().split())
	uNums = []
	for num in nums:
		if num not in uNums:
			uNums.append(num)
	print(' '.join(uNums))


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	dict_one = {}
	for i in range(2 * n):
		if arr[i] in dict_one:
			dict_one[arr[i]] += 1
		else:
			dict_one[arr[i]] = 1
	ans = []
	for i in range(2 * n):
		if dict_one[arr[i]] != 0:
			for j in range(dict_one[arr[i]] // 2):
				ans.append(arr[i])
			dict_one[arr[i]] = 0
	print(*ans)


def ans(n, arr):
	l = []
	for i in arr:
		if i not in l:
			l.append(i)
	return l
t = int(input())
L = []
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	L.append(ans(n, arr))
for l in L:
	for s in l:
		print(s, end=' ')
	print()


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
import random
import re
import heapq
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	s = set()
	v = []
	for a in arr:
		if a not in s:
			s.add(a)
			v.append(a)
	print(' '.join(map(str, v)))


for i in range(int(input())):
	n = int(input())
	s = [int(i) for i in input().split()]
	e = set()
	d = []
	for i in s:
		if i not in e:
			d.append(i)
			e.add(i)
	print(*d)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	w = []
	m = {}
	for num in l:
		if m.get(num, 1):
			w.append(num)
			m[num] = 0
	print(' '.join([str(x) for x in w]))


for t in range(int(input())):
	(n, s, a) = (input(), set(), input().split())
	for e in a:
		if e not in s:
			print(e, end=' ')
			s.add(e)
	print()


from collections import OrderedDict
for i in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	o = OrderedDict()
	for i in l:
		if not o.get(i, 0):
			o[i] = 1
	print(*o.keys())


y = int(input())
for i in range(y):
	n = int(input())
	al = input().split()
	m = list(map(int, al))
	a = []
	d = {}
	for j in m:
		d.setdefault(j, 0)
		d[j] += 1
		if d[j] == 1:
			a.append(j)
	for j in a:
		print(j, end=' ', sep='')
	print()


t = int(input().strip())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().strip().split()))
	dic = {}
	first = True
	for i in a:
		if i not in dic:
			if not first:
				print(' ', end='')
			else:
				first = False
			print(i, end='')
			dic[i] = True
	print('')


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	num = [0 for i in range(51)]
	l1 = []
	for i in lis:
		if num[i] == 0:
			l1.append(i)
			num[i] = 1
	print(*l1)


t = int(input())
for i in range(t):
	n = int(input())
	ai = list(map(int, input().split()))
	ar = [0] * (n + 1)
	for i in range(2 * n):
		if ar[ai[i]] == 0:
			ar[ai[i]] = 1
			print(ai[i], end=' ')
	print()


import math
import bisect
import copy
import time
from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	ans = []
	for i in range(len(l)):
		if l[i] not in ans:
			ans.append(l[i])
	print(*ans)


for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	p = []
	done = set()
	for x in a:
		if x not in done:
			done.add(x)
			p.append(x)
	print(*p)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	i = 0
	q = []
	q1 = []
	while i < 2 * n:
		if l[i] not in q:
			q.append(l[i])
		else:
			q1.append(l[i])
		i += 1
	if q == q1:
		for x in q:
			print(x, end=' ')
		print()


for _ in range(int(input().strip())):
	n = int(input().strip())
	list = [int(x) for x in input().strip().split(' ')]
	ans = []
	ref = set()
	for x in list:
		if x not in ref:
			ref.add(x)
			ans.append(x)
	print(*ans)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	k = 0
	for j in range(0, 2 * n):
		if a[j] not in b:
			b.append(a[j])
			k = k + 1
		if k == n:
			break
	print(*b)


for _ in range(int(input())):
	n = int(input())
	arr = [int(y) for y in input().split()]
	seen = set()
	seen_add = seen.add
	ans = [x for x in arr if not (x in seen or seen_add(x))]
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	L = map(int, input().split())
	d = {}
	for i in L:
		if i not in d:
			d[i] = 1
	for i in d.keys():
		print(i, end=' ')
	print()


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	s = []
	for val in arr:
		if val not in s:
			s.append(val)
	print(*s)


t = int(input())
for _ in range(t):
	n = int(input())
	z = set()
	l = []
	curr = 0
	lol = [int(n) for n in input().split()]
	for i in lol:
		z.add(i)
		if len(z) > curr:
			l.append(i)
			curr += 1
	print(*l)


for i in range(int(input())):
	X = int(input())
	x = list(map(int, input().split()))
	y = []
	for j in range(1, X + 1):
		counter = 0
		for i in range(2 * X):
			if x[i] == j:
				counter += i + 1
		y.append(counter)
	z = []
	for k in y:
		z.append(y.index(min(y)) + 1)
		y[y.index(min(y))] = 1000
	print(*z, sep=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	ans = []
	for x in a:
		if x not in ans:
			ans.append(x)
	for x in ans:
		print(x, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(len(a)):
		if a[i] in b:
			continue
		else:
			b.append(a[i])
			print(a[i], end=' ')
	print()


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from collections import Counter
from bisect import bisect_left
import sys
from queue import PriorityQueue
import operator as op
from functools import reduce
mod = 1000000007

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def myCode():
	n = I()
	lst = L()
	d = defaultdict(int)
	for i in lst:
		if i in d:
			continue
		else:
			print(i, end=' ')
			d[i] += 1
	print()

def main():
	for t in range(I()):
		myCode()
main()


import math
from functools import reduce
from bisect import bisect
from collections import OrderedDict
t = int(input())
while t > 0:
	n = int(input())
	l = [int(x) for x in input().split()]
	res = list(OrderedDict.fromkeys(l))
	print(*res, sep=' ')
	t -= 1


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	dictt = Counter(arr)
	ls = []
	for i in arr:
		if dictt[i] == 2:
			ls.append(i)
			dictt[i] -= 1
	print(*list(ls))


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def calculate_sum(a, N):
	m = N / a
	sum = m * (m + 1) / 2
	ans = a * sum
	return ans

def series(N):
	return N * (N + 1) // 2

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def LCM(x, y):
	return x * y // GCD(x, y)

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def isprime(n):
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	n = inin()
	a = lin()
	temp = 0
	n = []
	for i in a:
		if n.count(i) == 0:
			n.append(i)
	print(*n)


t = int(input())
for i in range(t):
	a = int(input())
	k = list(map(int, input().split()))
	x = {}
	for i in k:
		if i in x:
			x[i] += 1
		else:
			x[i] = 1
	for (i, j) in x.items():
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	set1 = set(arr)
	main = []
	for i in arr:
		if i in set1:
			main.append(i)
			set1.remove(i)
	print(*main)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = [0] * (n + 1)
	for i in l:
		if f[i] == 0:
			print(i, end=' ')
			f[i] = 1
	print()


test = int(input())
for t in range(test):
	n = int(input())
	l = list(map(int, input().split()))
	s = set([])
	for i in l:
		if len(s) == n:
			break
		elif i in s:
			pass
		else:
			print(i, end=' ')
			s.add(i)
	print()


for tt in range(int(input())):
	l = []
	r = int(input())
	z = [int(i) for i in input().split()]
	for i in z:
		if i not in l:
			l.append(i)
	for i in l:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = input().split()
	lst = []
	for i in l:
		if i not in lst:
			lst.append(i)
			if len(lst) == n:
				break
	print(*lst)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a1 = []
	s1 = set()
	a2 = []
	for a_i in a:
		if a_i in s1:
			a2.append(a_i)
			s1.remove(a_i)
		else:
			a1.append(a_i)
			s1.add(a_i)
	s = ''
	for a1_i in a1:
		s += str(a1_i)
		s += ' '
	print(s)


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = []
	for j in b:
		if j not in c:
			c.append(j)
	print(*c)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = [0] * (n + 1)
	res = []
	for i in a:
		if l[i] == 0:
			res.append(str(i))
			l[i] = 1
	print(' '.join(res))


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * 2 * n
	l1 = []
	l2 = []
	for i in range(2 * n):
		if b[a[i]] == 0:
			b[a[i]] = 1
			l1.append(a[i])
		else:
			l2.append(a[i])
	i
	for i in range(n):
		print(l1[i], end=' ')
	print()
	t = t - 1


import math
t = int(input())
for _ in range(t):
	n = int(input())
	nums = [int(i) for i in input().split(' ')]
	was = [False] * (n + 1)
	sol = []
	for nn in nums:
		if not was[nn]:
			sol.append(nn)
			was[nn] = True
	print(*sol)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = [False] * n
	seq = []
	for x in l:
		if c[x - 1] == False:
			c[x - 1] = True
			seq.append(x)
	print(*seq)


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	history = []
	for i in arr:
		if i not in history:
			history.append(i)
	print(*history)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	lst1 = list(map(int, input().split()))
	dict1 = {}
	ans = []
	for i in range(len(lst1)):
		if lst1[i] in dict1:
			i += 1
		else:
			ans.append(lst1[i])
			dict1[lst1[i]] = 1
	for i in range(len(ans)):
		print(ans[i], end=' ')
	print()


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	di = {}
	for i in l:
		di[i] = di.get(i, 0) + 1
	li = list(di.keys())
	print(' '.join(map(str, li)))


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n
avl = AvlTree()

class SegmentTree1:

	def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	s = set()
	for i in range(n * 2):
		if l[i] not in s:
			ans.append(l[i])
			s.add(l[i])
	print(*ans)


t = int(input())
while t > 0:
	n = int(input())
	p = list(map(int, input().strip().split()))
	new = []
	new.append(p[0])
	for i in range(1, len(p)):
		if p[i] not in new:
			new.append(p[i])
	print(' '.join(map(str, new)))
	t = t - 1


T = int(input())
for _ in range(T):
	n = int(input())
	l = [int(x) for x in input().split(' ')]
	res = []
	seen_items = set()
	for x in l:
		if x not in seen_items:
			res.append(x)
			seen_items.add(x)
	print(*res, sep=' ')


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	a = list(dict.fromkeys(arr))
	print(*a)


import sys
input = sys.stdin.readline
f = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	n = input()
	a = f()
	dn = {}
	res = []
	for i in a:
		if not dn.get(i, False):
			res.append(i)
			dn[i] = True
	print(' '.join(map(str, res)))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	dic = {}
	ans = []
	for i in arr:
		try:
			if dic[i] == 1:
				continue
		except:
			dic[i] = 1
			ans.append(i)
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	sets = set()
	ans = []
	for i in range(2 * n):
		if arr[i] not in sets:
			ans += [arr[i]]
			sets.add(arr[i])
	for i in range(n):
		print(ans[i], end=' ')
	print()


for j in range(int(input())):
	n = int(input())
	l = []
	a = list(map(int, input().split()))
	l.append(a[0])
	for i in range(1, 2 * n):
		if a[i] not in l:
			l.append(a[i])
		if len(l) == n:
			break
	print(*l)


t = int(input())
for tt in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	p1 = []
	p2 = []
	for i in range(2 * n):
		if len(p1) == len(p2):
			p1.append(a[i])
		elif len(p1) > len(p2):
			if p1[len(p2)] == a[i]:
				p2.append(a[i])
			else:
				p1.append(a[i])
		elif p2[len(p1)] == a[i]:
			p1.append(a[i])
		else:
			p2.append(a[i])
	print(*p1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	q = []
	for i in l:
		if i not in q:
			q.append(i)
	print(*q)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))[0:2 * n]
	temp = [0] * n
	final = ''
	for i in arr:
		temp[i - 1] += 1
		if temp[i - 1] == 1:
			final += str(i) + ' '
	print(final)


from sys import stdin

def input():
	return stdin.readline()
for _ in range(int(input())):
	n = int(input())
	lst = [int(i) for i in input().split()]
	lst2 = []
	for i in lst:
		if i not in lst2:
			lst2.append(i)
			print(i, end=' ')
	print()


from sys import stdin
from math import ceil, gcd

def func():
	return
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	ans = []
	s = set()
	for i in range(2 * n):
		if arr[i] not in s:
			ans.append(arr[i])
			s.add(arr[i])
	print(*ans)


def prog():
	for _ in range(int(input())):
		n = int(input())
		visited = [0] * (n + 1)
		a = list(map(int, input().split()))
		perm = []
		for b in a:
			if not visited[b]:
				visited[b] = 1
				perm.append(str(b))
		print(' '.join(perm))
prog()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	original = []
	for i in arr:
		if i not in original:
			original.append(i)
	print(*original, sep=' ')


x = int(input())
for i in range(x):
	a = int(input())
	l = list(map(int, input().split()))
	f = list(set(l))
	for i in l:
		if i in f:
			print(i, end=' ')
			f.remove(i)


t = int(input())
for z in range(t):
	n = int(input())
	b = [True] * n
	for i in input().split():
		if b[int(i) - 1]:
			b[int(i) - 1] = False
			print(i)


n = int(input())
for i in range(n):
	lst = []
	n1 = int(input())
	n2 = list(map(int, input().split()))
	for j in n2:
		if j not in lst:
			lst.append(j)
	v = ' '.join((str(i) for i in lst))
	print(v)


from sys import stdout
from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	v = [0] * n
	l = list(map(int, input().split()))
	for i in l:
		if v[i - 1] == 0:
			stdout.write(str(i) + ' ')
			v[i - 1] = 1
	stdout.write('\n')


cases = int(input())
for i in range(cases):
	length = int(input())
	alist = list(map(int, input().split()))
	newlist = []
	adict = {}
	for p in range(1, length + 1):
		adict[alist.index(p)] = p
	sssdict = sorted(adict)
	for l in sssdict[:len(sssdict) - 1]:
		print(adict[l], end=' ')
	print(adict[sssdict[-1]])


k = int(input())
for i in range(k):
	n = int(input())
	lista = list()
	lista2 = list()
	vis = list()
	vis = [0] * n
	a = input().split()
	for abc in a:
		lista.append(int(abc))
	for j in range(2 * n):
		aux = lista[j]
		if vis[aux - 1] == 0:
			vis[aux - 1] = 1
			lista2.append(aux)
	for j in lista2:
		print(j, end=' ')
	print()


def solve(l):
	s = set()
	ans = []
	for n in l:
		if n not in s:
			ans.append(n)
			s.add(n)
	print(' '.join(list(map(str, ans))))

def loop():
	t = int(input())
	for _ in range(t):
		_ = input()
		l = list(map(int, input().split()))
		solve(l)
loop()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	g = 1
	a1 = []
	a1.append(a[0])
	for j in range(2 * n):
		for k in range(g, 2 * n):
			if a[j] != a[k]:
				a1.append(a[k])
			else:
				g = k + 1
				break
	f = []
	for h in range(len(a1)):
		if (a1[h] in f) == False:
			f.append(a1[h])
			print(a1[h], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))
	c = 0
	for i in range(len(l) - 1):
		x = l[i]
		for j in range(i + 1, len(l)):
			if x == l[j]:
				c = c + 1
		if c > 0:
			print(l[i], end=' ')
		c = 0
	print()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	n = int(inp())
	a = lis()
	visited = [0] * (n + 1)
	ans = []
	for i in range(2 * n):
		if visited[a[i]] == 0:
			ans.append(a[i])
			visited[a[i]] = 1
		else:
			continue
	print(' '.join((str(ans[i]) for i in range(len(ans)))))
testcase(int(inp()))


import math
a = int(input())
for i in range(a):
	b = int(input())
	ar = list(map(int, input().strip().split()))
	br = []
	for i in ar:
		if i not in br:
			br.append(i)
			print(i, end=' ')
	print()


import sys
t = int(sys.stdin.readline().strip())
while t:
	n = int(sys.stdin.readline().strip())
	arr = list(map(int, sys.stdin.readline().strip().split()))
	ans = []
	sett = set()
	for i in range(2 * n):
		if arr[i] in sett:
			continue
		ans.append(arr[i])
		sett.add(arr[i])
	print(*ans)
	t -= 1


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	A = rl()
	out = []
	seen = set()
	for a in A:
		if a not in seen:
			seen.add(a)
			out.append(a)
	print(*out)
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


t = int(input())
for i in range(t):
	uni_len = int(input())
	input_string = input()
	input_data = input_string.split(' ')
	input_data = [int(x) for x in input_data]
	list_we_want = []
	list_we_want.append(input_data[0])
	for num in range(2 * uni_len - 1):
		if input_data[num + 1] in list_we_want:
			continue
		else:
			list_we_want.append(input_data[num + 1])
	for j in range(uni_len):
		print(list_we_want[j], end=' ')


t = int(input())
while t > 0:
	n = int(input())
	x = list(map(int, input().split()))
	a = list()
	a.append(x[0])
	for i in range(1, 2 * n):
		if x[i] not in a:
			a.append(x[i])
		if len(a) == n:
			break
	for ele in a:
		print(ele, end=' ')
	print()
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in a:
		if i not in ans:
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	another = []
	arr = list(map(int, input().split(' ')))
	for i in range(len(arr)):
		if arr[i] not in another:
			another.append(arr[i])
	print(*another)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	n = ii()
	a = il()
	k = []
	for i in range(0, 2 * n):
		if a[i] not in k:
			k.append(a[i])
	print(*k)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	was = [False] * n
	ans = []
	for j in range(2 * n):
		if not was[a[j] - 1]:
			ans.append(a[j])
			was[a[j] - 1] = True
	print(*ans)


count = int(input())
output = []
for i in range(count):
	length = int(input())
	mas = input().split()
	buffer = []
	for i in mas:
		if i not in buffer:
			buffer.append(i)
		if len(buffer) == length:
			break
	output.append(buffer)
for i in output:
	for k in i:
		print(k, end=' ')
	print()


test = int(input())
i = 0
while i < test:
	length = int(input())
	lst = list(map(int, input().split()))
	for j in range(length):
		lst.remove(j + 1)
	for k in range(length):
		print(lst[k], end=' ')
	i += 1


for _ in range(int(input())):
	n = int(input())
	seen = set()
	ans = []
	for x in map(int, input().split()):
		if x not in seen:
			ans.append(str(x))
		seen.add(x)
	print(' '.join(ans))


import collections
T = int(input())
for i in range(T):
	d = collections.OrderedDict()
	N = int(input())
	A = list(map(int, input().split()))
	for i in range(2 * N):
		try:
			d[A[i]] += 1
		except:
			d[A[i]] = 1
	print(*d.keys())


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	d1 = {}
	for i in arr:
		if i not in d1:
			d1[i] = 1
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	print(' '.join([str(i) for i in list(set(arr))]))


n = int(input())
while n > 0:
	n -= 1
	c = int(input())
	p = list(map(int, input().split()))
	p2 = p
	p_set = set(p)
	for i in p2:
		if {i} & p_set == {i}:
			print(i, end=' ')
			p_set.remove(i)


t = int(input())
for i in range(0, t):
	n = int(input())
	L = list(map(int, input().split()))
	M = [False] * (n + 1)
	N = []
	for i in range(0, 2 * n):
		if not M[L[i]]:
			N.append(L[i])
			M[L[i]] = True
	print(*N)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	for i in s:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = list()
	for k in l:
		if k not in ans:
			ans.append(k)
	print(*ans)


import math
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mrk = [1 for i in range(n * 2)]
	ans = ''
	for i in range(n * 2 - 1, -1, -1):
		if mrk[i] == 1:
			ans = ' ' + str(arr[i]) + ans
			mrk[i] = 0
			for j in range(n * 2):
				if arr[j] == arr[i] and mrk[j] == 1:
					mrk[j] = 0
					break
	print(ans[1:])


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	print(*b)


t = int(input())
for i in range(0, t):
	str1 = ''
	n = int(input())
	lst = list((int(num) for num in input().split()))[:2 * n]
	unique = []
	for ele in lst:
		if ele not in unique:
			unique.append(ele)
	for i in range(len(unique)):
		str1 = str1 + str(unique[i]) + ' '
	print(str1)


n = int(input())
for i in range(n):
	r = int(input())
	x = list(map(int, input().split()))
	c = []
	for i in x:
		if i not in c:
			c.append(i)
	for i in c:
		print(i, end=' ')
	print('')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		n = int(input())
		arry = list(map(int, input().split()))
		dic = {}
		ans = []
		for ele in arry:
			res = dic.get(ele, False)
			if not res:
				ans.append(ele)
			dic[ele] = True
		yield ' '.join((str(x) for x in dic))
t = int(input())
ans = gift()
print(*ans, sep='\n')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = set([])
	c = []
	for i in range(2 * n):
		if a[i] not in b:
			b.add(a[i])
			c.append(a[i])
	print(*c)


t = int(input())
for _ in range(t):
	n = int(input())
	sosu = [int(i) for i in input().split()]
	check = [0] * int(n + 1)
	a = []
	for i in sosu:
		if check[i] == 0:
			check[i] = 1
			a.append(i)
	print(*a)


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p1 = []
	used = set()
	for val in a:
		if val not in used:
			used.add(val)
			p1.append(val)
	print(*p1)


t = int(input(''))
while t > 0:
	n = int(input(''))
	l = list(map(int, input().split()))
	per = []
	for i in l:
		if i not in per:
			per.append(i)
	for j in per:
		print(j, end=' ')
	print()
	t -= 1


import sys
for i in range(0, int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	alpres = [0] * n
	out = []
	for b in l:
		if alpres[b - 1] == 0:
			out.append(str(b))
		alpres[b - 1] += 1
	sys.stdout.write(' '.join(out) + '\n')


T = int(input())
for i in range(T):
	n = int(input())
	n_ints = [int(i) for i in input().split()]
	wr = set(n_ints)
	s = ''
	for i in n_ints:
		if i in wr:
			print(i, end=' ')
			wr.remove(i)
	print('\n')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = li()
	visited = {}
	ans = []
	for i in l:
		if i not in visited:
			ans.append(i)
		visited[i] = 1
	print(*ans)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	d = defaultdict(lambda : 0)
	res = []
	a = list(map(int, input().split()))
	for i in range(n << 1):
		if d[a[i]] == 0:
			res.append(a[i])
			d[a[i]] = 1
	print(*res)


t = int(input())
while t:
	n = int(input())
	l = []
	l = input().split()
	uniq = []
	[uniq.append(x) for x in l if x not in uniq]
	for x in uniq:
		print(x, end=' ')
	print()
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	n2 = list(map(int, input().split()))
	p = [0] * n
	k = 0
	j = 0
	while p[n - 1] == 0:
		if n2[k] not in p:
			p[j] = n2[k]
			j += 1
		k += 1
	print(*p)


count = int(input())
for _ in range(count):
	d = int(input())
	a = input().split()
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	i = ' '.join(b)
	print(i)


from collections import OrderedDict
for _ in range(int(input())):
	n = int(input())
	aa = list(map(int, input().split()))
	aa = list(OrderedDict.fromkeys(aa))
	for x in aa:
		print(x, end=' ')


try:
	t = int(input())
	for i in range(t):
		n = int(input())
		l = list(map(int, input().split()))
		l1 = []
		for i in range(2 * n):
			if l[i] not in l1:
				l1.append(l[i])
		for i in range(n):
			print(l1[i], end=' ')
		print()
except:
	pass


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	flag = [0] * (n + 1)
	for ele in a:
		if flag[ele] == 0:
			print(ele, end=' ')
			flag[ele] = 1
	print()


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	n = int(inputi())
	aa = [int(a) for a in inputi().split()]
	pp = []
	found = [False] * (n + 1)
	for a in aa:
		if not found[a]:
			pp.append(a)
			found[a] = True
	print(' '.join(map(str, pp)))

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


t = int(input())
for i in range(t):
	ans = []
	n = int(input())
	List = [int(x) for x in input().split()]
	for j in List:
		if j not in ans:
			ans.append(j)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	datas = list(map(int, input().split()))
	per = [0] * n
	for data in datas:
		if per[data - 1]:
			continue
		print(data, end=' ')
		per[data - 1] = 1
	print()


for test_case in range(int(input())):
	length = int(input())
	arr = list(map(int, input().split()))
	ans = []
	for x in arr:
		if x not in ans:
			ans.append(x)
	print(*ans)


t = int(input())
for i in range(t):
	print()
	x = int(input())
	lst = list(map(int, input().split()))
	y = []
	for j in lst:
		if j not in y:
			y.append(j)
	for k in y:
		print(k, end=' ')


for _ in range(int(input())):
	fi = []
	n = int(input())
	li = list(map(int, input().strip().split()))
	while len(li) != 0:
		a = li[-1]
		fi.append(a)
		li = list(filter(a.__ne__, li))
	for i in range(n):
		print(str(fi[n - 1 - i]) + ' ', end='')
	print('')


t = int(input())
while t > 0:
	n = int(input())
	arr = input().split()
	arr = [int(i) for i in arr]
	arr1 = []
	for i in arr:
		if i not in arr1:
			arr1.append(i)
	print(*arr1, sep=' ')
	t -= 1


for ij in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	l = []
	for i in lis:
		if i not in l:
			l.append(i)
	for i in l:
		print(i, end=' ')
	print()


import math
from collections import *
import sys
from functools import reduce
from itertools import groupby

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [[0, 1], [0, -1], [1, 0], [1, -1]]
NEIGHBOURS = [(i, j) for i in range(-1, 2) for j in range(-1, 2) if i != 0 or j != 0]
OrdUnicode_a = ord('a')
OrdUnicode_A = ord('A')
CAPS_ALPHABETS = {chr(i + OrdUnicode_A): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + OrdUnicode_a): i for i in range(26)}
MOD_JOHAN = int(1000000000.0) + 7
MOD_LIGHT = 998244353
INFINITY = float('inf')
MAXN_EYEPATCH = int(100000.0) + 1
MAXN_FULLMETAL = 501
for _testcases_ in range(int(input())):
	n = int(input())
	li = get_list()
	found = [False] * (n + 1)
	for i in li:
		if not found[i]:
			found[i] = True
			printsp(i)
	print()


for _ in range(int(input())):
	x = int(input())
	n = [i for i in input().split()]
	result = list()
	for j in range(len(n)):
		if n[j] in result:
			continue
		else:
			result.append(n[j])
	print(' '.join(result))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	v = [0] * (n + 1)
	ans = []
	for i in a:
		if v[i] == 0:
			v[i] = 1
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	visited = [0] * (n + 1)
	a = list(map(int, input().split()))
	final = []
	for i in a:
		if visited[i]:
			continue
		else:
			final.append(i)
			visited[i] = 1
	print(*final)


rr = lambda : input()
rri = lambda : int(input())
rrm = lambda : list(map(int, input().split()))
INF = float('inf')

def solve(N, arr):
	ans = []
	seen = set()
	for v in arr:
		if v not in seen:
			seen.add(v)
			ans.append(v)
	return ' '.join(list(map(str, ans)))
t = rri()
for _ in range(t):
	n = rri()
	arr = rrm()
	print(solve(n, arr))


test = int(input())
while test > 0:
	n = input()
	li = [int(x) for x in input().split()]
	salman = {}
	for i in li:
		if i in salman:
			salman[i] += 1
		else:
			salman[i] = 1
	lisp = list(salman)
	for k in lisp:
		if k == lisp[-1]:
			print(k)
		else:
			print(k, end=' ')
	test -= 1


for _ in range(int(input())):
	x = int(input())
	a = list(map(int, input().split()))
	b = list()
	for i in a:
		if i not in b:
			b.append(i)
	for i in b:
		print(i, end=' ')
	print()


for _ in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().strip().split()))
	counter = 0
	res = []
	hashmap = [-1 for a in range(0, n + 1)]
	for i in l:
		if hashmap[i] == -1:
			counter += 1
			hashmap[i] = 0
			res.append(i)
	print(' '.join((str(x) for x in res)))


for _ in range(int(input())):
	n = int(input())
	data = [int(x) for x in input().split()]
	ans1 = []
	pivot = 0
	ans1.append(data[0])
	for q in data[1:]:
		try:
			if q == ans1[pivot]:
				pivot += 1
			else:
				ans1.append(q)
			if pivot == n:
				break
		except:
			ans1.append(q)
	for q in ans1:
		print(q, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	arr = input().split()
	dic = {}
	order = []
	for j in range(2 * n):
		if arr[j] not in dic:
			dic[arr[j]] = 1
			order.append(arr[j])
	print(' '.join(order))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	se = set({})
	ans = []
	for i in ar:
		if not i in se:
			se.add(i)
			ans.append(i)
	print(*ans)


for i in range(int(input())):
	n = int(input())
	m = [int(a) for a in input().split()]
	ans = list()
	for j in m:
		if not j in ans:
			ans.append(j)
	for j in ans:
		print(j, end=' ')
	print()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	seen = set()
	ans = []
	for item in p:
		if item not in seen:
			seen.add(item)
			ans.append(str(item))
	print(' '.join(ans))


for i in range(int(input())):
	n = int(input())
	a = input().split()
	p1 = []
	p2 = []
	index = 0
	for (i, val) in enumerate(a):
		if len(p2) == len(p1):
			p2.append(val)
		elif val == p2[index]:
			p1.append(val)
			index += 1
		else:
			p2.append(val)
	print(' '.join((str(s) for s in p1)))


t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for i in range(n * 2):
		if a[i] not in p:
			p.append(a[i])
	for i in range(n):
		print(p[i], end=' ')
	print()


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	check = [False] * n
	for i in range(2 * n):
		x = a[i] - 1
		if not check[x]:
			ans.append(x + 1)
			check[x] = True
	print(*ans)


for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = []
	for j in a:
		if j not in b:
			b.append(j)
	print(*b)


t = int(input(''))
for i in range(t):
	n = int(input(''))
	p = input('').split(' ')
	res = []
	for c in p:
		if not c in res:
			res.append(c)
	for rr in res:
		print(rr, end=' ')
	print('')


from sys import stdin
for _ in range(int(input())):
	a = int(stdin.readline().rstrip())
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	az = []
	for i in range(a * 2):
		if l[i] not in az:
			az.append(l[i])
	print(*az)


I = input
for _ in range(int(I())):
	n = int(I())
	a = list(map(int, I().split()))
	d = dict()
	for i in a:
		if i in d:
			continue
		else:
			d[i] = 1
	print(*list(d.keys()))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l1 = []
	l2 = []
	for i in range(0, 2 * n):
		if a[i] not in l1:
			l1.append(a[i])
		else:
			l2.append(a[i])
	for i in range(0, n):
		print(l1[i], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = []
	for i in l:
		if i not in s:
			s.append(i)
	print(*s)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	Set = set()
	for i in range(2 * n):
		if l[i] not in Set:
			Set.add(l[i])
			print(l[i], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = [0] * n
	j = 0
	for i in a:
		if i not in p:
			p[j] = i
			j += 1
	print(' '.join(map(str, p)))


t = int(input())
while t > 0:
	n = int(input())
	p = [int(ele) for ele in input().split()]
	num = {}
	for i in range(1, n + 1):
		num[i] = 0
	for ele in p:
		if num[ele] == 0:
			num[ele] = 1
			print(ele, end=' ')
	print()
	t -= 1


n = int(input())
for i in range(n):
	x = int(input())
	l = list(map(int, input().split()))
	l1 = []
	for j in range(len(l)):
		if l[j] not in l1:
			l1.append(l[j])
	for j in l1:
		print(j, end=' ')
	print('')


from collections import OrderedDict
t = int(input())
for _ in range(1, t + 1):
	n = int(input())
	elements = [int(x) for x in input().split()]
	ans = OrderedDict()
	for element in elements:
		if element not in ans:
			ans[element] = 1
	print(' '.join(map(str, ans.keys())))


for t in range(int(input())):
	n = int(input())
	s = {i for i in map(int, input().split())}
	for i in s:
		print(i, end=' ')
	print()


nCases = int(input())
for _ in range(nCases):
	pLen = int(input())
	doub = [int(x) for x in input().split()]
	perm = []
	for val in doub:
		if val not in perm:
			perm.append(val)
	for val in perm:
		print(val, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	set1 = set()
	result = []
	for i in list1:
		if i not in set1:
			result.append(i)
		set1.add(i)
	print(*result)


t = int(input())
d = [[] for i in range(t)]
for i in range(t):
	d[i].append(int(input()))
	d[i].append(list(map(int, input().split())))
b = []
for i in range(t):
	for j in range(len(d[i][1])):
		if len(b) == d[i][0]:
			b = []
			break
		elif not d[i][1][j] in b:
			b.append(d[i][1][j])
			print(d[i][1][j], end=' ')
	print()


from collections import Counter
import math

def solve():
	n = int(input())
	array = list(map(int, input().split()))
	Dict = {}
	for i in array:
		try:
			if Dict[i] == 1:
				continue
		except:
			Dict.setdefault(i, 1)
			print(i, end=' ')
	print()
for i in range(int(input())):
	solve()


T = int(input())
while T > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	visited = [False] * (n + 1)
	for i in range(2 * n):
		if visited[arr[i]] is False:
			res.append(arr[i])
		visited[arr[i]] = True
	print(*res)
	T -= 1


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = []
	d = {}
	for e in l:
		if e not in a:
			a.append(e)
	print(*a)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		s = set()
		r = []
		for c in a:
			if c in s:
				continue
			s.add(c)
			r.append(c)
		rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


a = input()
for x in range(int(a)):
	b = int(input())
	c = input().split(' ')
	list1 = []
	for i in c:
		if i not in list1:
			list1.append(i)
	print(' '.join(list1))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(*set(a))


for i in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	r = []
	for i in m:
		if not i in r:
			r.append(i)
	print(*r)


t = int(input())
while t > 0:
	n = int(input())
	l = [int(i) for i in input().split()]
	a = []
	for i in l:
		if a.count(str(i)) == 0:
			a.append(str(i))
		if len(a) == n:
			break
	print(' '.join(a))
	t -= 1


for i in range(int(input())):
	p = int(input())
	l = list(map(int, input().split()))
	li = []
	for i in l:
		if i not in li:
			li.append(i)
	print(*li, sep=' ')


from bisect import bisect_left
from math import ceil
from math import radians
from heapq import heapify, heappush, heappop
import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li1():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0 and i % 2 == 1:
			s.add(i)
			n = n // i
	if n > 2 and n % 2 == 1:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count

def cou(n):
	c = 0
	while n > 1:
		c += 1
		n //= 2
	return c

def sortsec(l):
	return sorted(l, key=lambda x: x[1])

def BinarySearch(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1
for _ in range(ii()):
	n = ii()
	l = li1()
	out = []
	b = [0] * (n + 1)
	for i in l:
		if b[i] == 0:
			out.append(i)
			b[i] = 1
	print(*out)


import sys
for _ in range(int(sys.stdin.readline().rstrip())):
	n = int(sys.stdin.readline().rstrip())
	a = list(map(int, sys.stdin.readline().rstrip().split()))
	check = [0] * (2 * n)
	result = []
	check[0] = 1
	x = 0
	y = 0
	for i in range(1, 2 * n):
		if a[i] == a[0]:
			y = i
			check[y] = 1
			break
	result.append(a[0])
	x = 0
	while True:
		if len(result) == n:
			break
		while True:
			if check[x] == 0:
				break
			x += 1
		while True:
			if check[y] == 0 and a[x] == a[y] and (x < y):
				check[y] = 1
				check[x] = 1
				result.append(a[x])
				break
			y += 1
	for i in result:
		print(i, end=' ')
	print()


import math
from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	seq = []
	d1 = defaultdict(int)
	for x in a:
		if d1[x] == 0:
			seq.append(x)
			d1[x] += 1
	print(' '.join((str(x) for x in seq)))


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for i in range(ii()):
	visited = [0 for i in range(51)]
	n = ii()
	arr = list(mi())
	res = []
	for i in arr:
		if visited[i] == 0:
			res.append(i)
			visited[i] = 1
	print(*res)


for i in range(int(input())):
	input()
	b = list(map(int, input().split()))
	v = []
	for i in range(len(b)):
		if b[i] in v:
			pass
		else:
			v.append(b[i])
	print(*v)


for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	a = []
	for i in arr:
		if i not in a:
			print(i, end=' ')
			a.append(i)
	print()


from collections import defaultdict

def solve():
	n = int(input())
	x = list(map(int, input().split()))
	extra = defaultdict(int)
	out = []
	for i in x:
		extra[i] += 1
		if extra[i] == 1:
			out.append(i)
	print(*out)
t = int(input())
for test in range(t):
	solve()


n = int(input())
for i in range(n):
	size = int(input())
	arr = [int(i) for i in input().split()]
	ans = []
	for e in range(len(arr)):
		if arr[e] not in ans:
			ans.append(arr[e])
	for k in ans:
		print(k, end=' ')


t = int(input())
for i in range(0, t):
	n = int(input())
	ls = list(map(int, input().rstrip().split()))
	ls1 = []
	jj = 0
	for j in ls:
		if j not in ls1:
			ls1.append(j)
			jj += 1
		else:
			pass
		if jj == n:
			break
	print(*ls1)


def stdin(t):
	for _ in range(t):
		n = int(input())
		a = [int(x) for x in input().split()]
		print(main(n, a))

def main(n, a):
	last = a[-1]
	res = []
	for obj in a:
		if str(obj) not in res and obj != last:
			res.append(str(obj))
	res.append(str(last))
	return ' '.join(res)
stdin(int(input()))


n = int(input())
for i in range(n):
	w = []
	n = int(input())
	visited = []
	c = list(map(int, input().split()))
	for j in range(len(c)):
		if c[j] not in visited:
			visited.append(c[j])
	print(*visited)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
from sys import stdin, stdout
from collections import Counter
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def lessThanX(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def BinarySearch(a, x):
	i = bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def main():
	for i in range(ip()):
		n = ip()
		li = ai()
		ans = []
		s = set()
		for i in li:
			if i not in s:
				s.add(i)
				ans.append(i)
		print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
ip = lambda : int(sys.stdin.readline().rstrip('\r\n'))
ai = lambda : list(map(int, sys.stdin.readline().split()))
ei = lambda : map(int, sys.stdin.readline().split())
main()


t = input()
t = int(t)
while t > 0:
	t = t - 1
	ara = list()
	lst = list()
	n = input()
	n = int(n) * 2
	m = int(n)
	inp = input()
	inp = inp.split()
	for num in inp:
		if num not in lst:
			lst.append(num)
	cnt = 0
	itr = int(m)
	for num in lst:
		print(num)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	q = set(p)
	for i in a:
		if i not in q:
			p.append(i)
			q = set(p)
	print(*p)


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * (n + 1)
	for i in a:
		if b[i] == 0:
			b[i] = 1
			print(i, end=' ')
	print('')


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	m = input()
	a = list(map(int, m.split()))
	p = []
	for i in range(2 * n):
		if a[i] not in p:
			p.append(a[i])
		else:
			continue
	ans.append(p)
for i in ans:
	print(*i)


t = int(input())
for i in range(1, t + 1):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in range(len(a)):
		if a[i] not in l:
			l.append(a[i])
	for i in range(len(l)):
		print(l[i], end=' ')


t = int(input())
final = []
for i in range(t):
	size = int(input())
	inputs = list(map(int, input().split()))
	outputs = [0]
	for i in inputs:
		flag = 1
		for j in outputs:
			if i == j:
				flag = 0
		if flag == 1:
			outputs.append(i)
	outputs.remove(0)
	final.append(outputs)
for k in final:
	for l in k:
		print(l, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	dic = {}
	for j in a:
		if j in dic:
			continue
		else:
			dic[j] = 1
			ans.append(j)
	for j in ans:
		print(j, end=' ')
	print()


t = int(input())
for _ in range(t):
	z = int(input())
	k = list(map(int, input().split()))
	c = []
	for i in k:
		if i not in c:
			c.append(i)
			print(i, end=' ')
	print()


def aman(s):
	p = []
	for i in range(len(s)):
		if s[i] not in p:
			p.append(s[i])
	return p
t = int(input())
for i in range(t):
	a = int(input())
	s = list(map(int, input().rstrip().split()))
	res = aman(s)
	print(' '.join(map(str, res)))


def main():
	for t in range(int(input())):
		n = int(input())
		a = [int(x) for x in input().split()]
		s = set()
		l = []
		for i in a:
			if i not in s:
				l.append(i)
				s.add(i)
		for i in l:
			print(i, end=' ')
		print()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys, math
mod = 10 ** 9 + 7
md = 998244353
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n,) = inp()
	a = list(map(int, input().split()))
	d = set()
	ans = []
	for i in a:
		if i not in d:
			ans.append(i)
			d.add(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	s = set()
	for i in map(int, input().split()):
		if i not in s:
			print(i, end=' ')
		s.add(i)
	print()


t = int(input())
for x in range(t):
	n = int(input())
	l = [int(l) for l in input().split()]
	l1 = []
	for i in l:
		if i not in l1:
			l1.append(i)
	for i in l1:
		print(i, end=' ')
	print()


for g in range(int(input())):
	N = int(input())
	K = list(map(int, input().split()))
	P = []
	for c in K:
		if c not in P:
			P.append(c)
			print(c, end=' ')
	print()


from sys import stdin as sin
for _ in range(int(sin.readline())):
	n = int(sin.readline())
	l = list(map(int, sin.readline().split(' ')))
	v = [0] * n
	ans = []
	for i in l:
		if v[i - 1] == 0:
			v[i - 1] = 1
			ans.append(i)
	print(*ans, sep=' ')


for i in range(int(input())):
	n = int(input())
	peres = list(map(int, input().split()))
	rang = set((i for i in range(1, n + 1)))
	a = []
	j = 0
	while len(rang) > 0:
		if peres[j] in rang:
			a.append(peres[j])
			rang.remove(peres[j])
		j = j + 1
	print(' '.join((str(j) for j in a)))


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		ans = []
		s = input()
		s = s.split(' ')
		for k in s:
			if k not in ans:
				ans.append(k)
		str1 = ''
		for m in ans:
			str1 += m + ' '
		print(str1)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	list1.reverse()
	for i in range(1, n + 1):
		list1.remove(i)
	print(*list1[::-1])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [0] * (n + 1)
	for i in input().split():
		num = int(i)
		if arr[num] == 0:
			print(i, end=' ')
			arr[num] = 1
	print()


t = int(input())
for i in range(t):
	s = int(input())
	a = list(map(int, input().split()))
	p = [False for i in range(s)]
	ans = []
	for j in range(len(a)):
		x = a[j]
		if p[x - 1] == False:
			ans.append(x)
			p[x - 1] = True
	print(*ans)


t = int(input())
for l in range(t):
	n = int(input())
	lst = list(map(str, input().strip().split()))[:2 * n]
	counts = dict()
	for item in lst:
		counts[item] = counts.get(item, 0) + 1
	s = ''
	for k in counts:
		s = s + k + ' '
	print(s)


T = int(input())
for t in range(T):
	n = input()
	inp = list(map(int, input().split(' ')))
	l = []
	for e in inp:
		if e not in l:
			l.append(e)
	l = map(str, l)
	print(' '.join(l))


t = int(input())
for case in range(t):
	input()
	inp = []
	for AAA in input().split(' '):
		if not AAA in inp:
			inp.append(AAA)
	print(' '.join(inp))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = list(map(int, input().strip().split(' ')))
		s = set()
		for i in arr:
			if i not in s:
				s.add(i)
				print(i, end=' ')
		print()
main()


t = int(input())
ans = {}
while t:
	n = int(input())
	line = input().split()
	ans = []
	for el in line:
		if el not in ans:
			ans.append(el)
	print(' '.join(ans))
	t -= 1


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in range(0, len(a)):
		if a[i] not in l:
			l.append(a[i])
		if len(l) == n:
			break
	print(*l)


def f(n, l):
	out = []
	for i in l:
		if i not in out:
			out.append(i)
	print(*out)
for _ in range(int(input())):
	f(int(input()), [int(x) for x in input().split()])


def rest(x):
	res = []
	for v in x:
		if v not in res:
			res.append(v)
	return res
for _ in range(int(input())):
	input()
	print(*rest(map(int, input().split())))


for _ in range(int(input())):
	n = int(input())
	(*arr,) = map(int, input().split())
	res = []
	used = [False] * n
	for num in arr:
		if not used[num - 1]:
			res.append(num)
		used[num - 1] = True
	print(*res)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for x in a:
		if x not in b:
			b.append(x)
	print(*b)


for _ in range(int(input())):
	k = set()
	x = int(input())
	li = list(map(int, input().split()))
	a = []
	for i in li:
		if i not in k:
			k.add(i)
			a.append(i)
	print(*a)


nu = int(input())
for i in range(nu):
	nn = int(input())
	aa = list(map(int, input().split()))
	dd = []
	for k in range(len(aa)):
		if aa[k] not in dd:
			dd.append(aa[k])
	for j in dd:
		print(j, end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	stack = [-1, l[0]]
	ans = []
	for i in range(1, n * 2):
		if stack[-1] == l[i]:
			ans.append(stack.pop())
		else:
			stack.insert(1, l[i])
	print(' '.join(map(str, ans)))


tc = int(input())
for _ in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	x = dict()
	for i in arr:
		x[i] = 0
	for i in x.keys():
		print(i, end=' ')
	print()


t = int(input())
while t:
	n = int(input())
	a = [int(x) for x in input().split()]
	d = {}
	r = []
	for i in a:
		if i not in d:
			d[i] = True
			r.append(i)
	for i in r:
		print(i, end=' ')
	print()
	t -= 1


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		hashm = {}
		n = inp()
		a = inlt()
		ans = []
		for i in a:
			if i not in hashm:
				ans.append(i)
				hashm[i] = 1
		pr_list(ans)
main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	vis = set()
	arr_new = []
	for i in arr:
		if i not in vis:
			vis.add(i)
			arr_new.append(i)
	print(*arr_new)


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	a = []
	for i in p:
		if i not in a:
			a.append(i)
			if len(a) == n:
				break
	for i in a:
		print(i, end=' ')
	print()


tests = int(input())
for i in range(0, tests):
	List1 = []
	num = int(input())
	List = []
	List = input().split()
	for k in range(0, 2 * num):
		List[k] = int(List[k])
	for k in range(2 * num):
		if List[k] not in List1:
			List1.append(List[k])
	for j in range(num):
		print(List1[j], end=' ')


for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	chk = set()
	for i in range(2 * n):
		temp = []
		if l[i] not in chk:
			ele = l[i]
			chk.add(ele)
		else:
			continue
		for j in range(i, 2 * n):
			if l[j] == ele:
				temp.append(l[j])
		l1 += temp
	d = {}
	for i in l1:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in d:
		print(i, end=' ')
	print()


(a, d) = (int(input()), [])
for i in range(0, a):
	b = int(input())
	c = [int(i2) for i2 in input().split(' ')]
	f = [0] * 50
	for i2 in range(0, b * 2):
		f[c[i2] - 1] += 1
	for i2 in range(0, 50):
		for i3 in range(0, f[i2] // 2):
			del c[c.index(i2 + 1)]
	d.append(c)
for i in range(0, len(d)):
	print(*d[i])


for i in range(int(input())):
	dic = {}
	n = input()
	l = list(map(int, input().split()))
	for each in l:
		if each not in dic:
			dic[each] = 0
			print(each, end=' ')
		dic[each] += 1
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = [a[0]]
	for i in range(1, len(a)):
		if a[i] not in d:
			d.append(a[i])
	print(*d)


t = int(input())
while t > 0:
	n = input()
	l = map(str, input().split(' '))
	x = []
	for i in l:
		if x.count(i) == 0:
			x.append(i)
	print(' '.join(x))
	t = t - 1


for t in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	res = []
	for i in li:
		if i not in res:
			res.append(i)
			print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	permutation = []
	a = input().split()
	answer = []
	pointer = 0
	for i in range(n * 2):
		permutation.append(int(a[i]))
	for i in range(n * 2):
		if permutation[pointer] in answer:
			pointer = pointer + 1
		else:
			answer.append(permutation[pointer])
			pointer = pointer + 1
	final_answer = str(answer[0]) + ' '
	for i in range(1, len(answer)):
		final_answer = final_answer + str(answer[i]) + ' '
	print(final_answer)


s = int(input())
for a in range(s):
	h = int(input())
	i = list(map(int, input().split()))
	x = []
	for t in i:
		if t not in x:
			print(t, end=' ')
			x.append(t)


for z in range(int(input())):
	b = []
	c = 9
	a = int(input())
	b = list(map(int, input().split()))
	for j in range(len(b)):
		for i in range(j):
			if b[j] == b[i]:
				c = 8
				break
		if c != 8:
			print(b[j], end=' ')
		c = 9
	print('\n')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	a = []
	for i in l:
		d[i] = d.get(i, 0) + 1
		if d[i] == 1:
			a.append(i)
	print(*a)


t = int(input())
r = []
res = []
for i in range(0, t):
	n = int(input())
	a = [int(a) for a in input().split()]
	r.append(a)
for i in range(0, t):
	for j in range(0, len(r[i])):
		if r[i][j] not in res:
			res.append(r[i][j])
	for j in range(0, len(res)):
		if j == len(res) - 1:
			print(res[j])
		else:
			print(res[j], end=' ')
	res = []


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	used = set()
	ans = []
	for a in A:
		if a not in used:
			ans.append(a)
			used.add(a)
	print(*ans)


for i in range(int(input())):
	n = int(input())
	lis = [int(x) for x in input().split()]
	l = list()
	for j in lis:
		if j not in l:
			l.append(j)
	print(*l)


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for s in a:
		s = str(s)
		if s not in p:
			p.append(s)
	print(' '.join(p))
	i += 1


cases = eval(input())
for _ in range(cases):
	extra = input()
	list = input().split()
	final = []
	for e in list:
		if e not in final:
			final.append(e)
	print(' '.join(final))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	li = list(dict.fromkeys(l))
	for j in li:
		print(j, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	l = []
	for i in range(len(arr)):
		if arr[i] not in set(l):
			l.append(arr[i])
		if len(arr) == n:
			break
	print(' '.join([str(i) for i in l]))


def permuting(arr):
	permutation = []
	for i in range(len(arr)):
		if arr[i] not in permutation:
			permutation.append(arr[i])
	for i in range(n):
		print(permutation[i], end=' ')
	print()
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	permuting(arr)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = [0] * 100
	for i in range(2 * n):
		if l1[l[i]] == 0:
			l1[l[i]] = 1
			print(l[i], end=' ')
	print()


t = int(input())
for j in range(t):
	n = int(input())
	list1 = []
	list1 = map(int, input().split())
	l2 = []
	for i in list1:
		if i not in l2:
			l2.append(i)
	for i in l2:
		print(i, end=' ')
	print()


def Remove(duplicate):
	final_list = []
	for num in duplicate:
		if num not in final_list:
			final_list.append(num)
	return final_list
t = int(input())
for p in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = Remove(a)
	print(*a)


for tt in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	st = set(arr)
	res = []
	for i in range(len(arr)):
		if arr[i] not in res:
			res.append(arr[i])
		else:
			continue
	print(*res)


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	h = set()
	ans = []
	for x in a:
		if x not in h:
			h.add(x)
			ans.append(x)
			if len(ans) == n:
				break
	print(' '.join(map(str, ans)))


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = []
	fin = []
	for i in arr:
		if fin.count(i) != 1:
			fin.append(i)
	print(*fin)


def answer(n, A):
	d = {}
	res = []
	for i in A:
		if i not in d:
			res.append(i)
			d[i] = 1
	return res
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(*answer(n, arr))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for j in a:
		if j in ans:
			continue
		ans.append(j)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mp = {}
	for j in a:
		try:
			mp[str(j)] += 1
		except KeyError:
			mp[str(j)] = 1
	print(' '.join(list(mp.keys())))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	s = set()
	ans = []
	for i in a:
		if i not in s:
			s.add(i)
			ans.append(i)
	print(*ans)


for (_, arr) in [[input(), [int(x) for x in input().split()]] for _ in ' ' * int(input())]:
	x = []
	for c in arr:
		if c not in x:
			x.append(c)
	print(*x)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	ans = []
	mset = set()
	for i in range(2 * n):
		if len(ans) == n:
			break
		if a[i] not in mset:
			ans.append(a[i])
			mset.add(a[i])
	print(*ans)


test_cases = int(input())
for i in range(test_cases):
	length = int(input())
	array = [int(i) for i in input().split()]
	different_numbers = []
	for j in array:
		if j not in different_numbers:
			different_numbers.append(j)
	for y in different_numbers:
		print(y, end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	now = []
	for i in lis:
		if i not in now:
			now.append(i)
	now = list(map(str, now))
	print(' '.join(now))


t = int(input())
for _ in range(t):
	d = {}
	n = int(input())
	a = list(map(int, input().split()))
	s = ''
	for i in a:
		d[i] = 0
	for i in a:
		if d[i] == 0:
			s = s + str(i) + ' '
			d[i] = 1
	s = s[:-1]
	print(s)


t = int(input())
for i in range(t):
	(n, l, d) = (int(input()), list(map(int, input().split())), {})
	for i in range(2 * n):
		if l[i] in d:
			d[l[i]] += 1
		else:
			d[l[i]] = 1
	for i in range(2 * n):
		if d[l[i]] == 2:
			d[l[i]] = 1
			print(l[i], end=' ')
	print()


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	di = dict(Counter(ls))
	ans = []
	for i in ls:
		if di[i] > 0:
			ans.append(i)
			di[i] -= 2
	print(' '.join(map(str, ans)))


for t in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	seen = set()
	for i in A:
		if i not in seen:
			print(i, end=' ')
		seen.add(i)


tCases = int(input())
for _ in range(tCases):
	n = int(input())
	li = list(map(int, input().split()))
	dict = {}
	for i in li:
		if i in dict:
			continue
		else:
			dict.update({i: 1})
	for i in dict:
		print(i, end=' ')
	print()


from sys import stdin
t = int(stdin.readline().strip())
for _ in range(t):
	n = int(stdin.readline().strip())
	arr = [int(x) for x in stdin.readline().strip().split(' ')]
	exist = [0] * (n + 1)
	perm = []
	for num in arr:
		if exist[num] == 0:
			exist[num] = 1
			perm.append(num)
	print(' '.join(map(str, perm)))


t = int(input())
for i in range(t):
	n = int(input())
	b = [True] * n
	a = list(map(int, input().split()))
	for x in a:
		if b[x - 1]:
			print(x, end=' ')
			b[x - 1] = False
	print()


tst = int(input())
t = 1
while t <= tst:
	n = int(input())
	i = 0
	ls = list(map(int, input().split()))
	ans = []
	while i < len(ls):
		if ls[i] not in ans:
			print(ls[i], end=' ')
			ans.append(ls[i])
		i += 1
	print('\r')
	t += 1


t = int(input())

def fun(n, a):
	ans = []
	for i in range(2 * n):
		if ans.count(a[i]) == 0:
			ans.append(a[i])
	print(*ans, sep=' ')
while t:
	t -= 1
	n = int(input())
	a = [int(i) for i in input().split()]
	fun(n, a)


for _ in range(int(input())):
	x = int(input())
	myset = set(map(int, input().split()))
	for i in myset:
		print(i, end=' ')
	print('')


ans = []
n = int(input())
for i in range(n):
	m = int(input())
	vector = input().split()
	ans.append(list(dict.fromkeys(vector)))
for i in ans:
	print(' '.join(i))


def main():
	tc = int(input())
	for x in range(tc):
		N = int(input())
		arr = list(map(int, input().split()))
		arr = list(dict.fromkeys(arr))
		for i in arr:
			print(i, end=' ')
		print()
main()


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	s = []
	for i in range(2 * n):
		if a[i] not in s:
			s.append(a[i])
	print(*s)
	t = t - 1


t = int(input())
while t:
	n = int(input())
	arr = [int(i) for i in input().split()]
	us = dict()
	for i in arr:
		try:
			us[i] += 1
		except:
			us[i] = 1
	for i in us:
		print(i, end=' ')
	print()
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	order = []
	dict1 = dict()
	for j in range(2 * n):
		if dict1.get(l[j], 0) == 0:
			dict1[l[j]] = 1
		else:
			order.append(l[j])
	print(*order)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l = set(l)
	l = list(l)
	for i in range(n):
		print(l[i], end=' ')
	print()


def rp():
	n = int(input())
	x = [int(x) for x in input().split()]
	lst = []
	for i in x:
		if i not in lst:
			lst.append(i)
	print(*lst, end=' ')
t = int(input())
for i in range(t):
	r = rp()


t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	flag = [False] * (n + 5)
	val_list = list(map(int, input().strip().split(' ')))
	ret = list()
	for val in val_list:
		if not flag[val]:
			flag[val] = True
			ret.append(val)
	print(' '.join(map(str, ret)))


for i in range(int(input())):
	n = int(input())
	s = list()
	for x in list(map(int, input().split())):
		if x not in s:
			s.append(x)
	print(*s)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	visited = [False] * (n + 1)
	new_arr = []
	for i in l:
		if visited[i] == False:
			visited[i] = True
			new_arr.append(i)
	print(*new_arr)


t = int(input())
for x in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	dc = {}
	ans = []
	for i in range(len(arr)):
		if arr[i] not in dc or dc[arr[i]] % 2 != 0:
			dc[arr[i]] = 0
			ans.append(arr[i])
		else:
			dc[arr[i]] += 1
	print(' '.join(map(str, ans)))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = Counter(a)
	b = []
	for i in range(2 * n):
		if d[a[i]] == 2:
			b += [a[i]]
			d[a[i]] -= 1
	print(*b)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	lst = []
	for j in a:
		if j not in lst:
			lst.append(j)
	print(' '.join((str(j) for j in lst)))


tests = int(input())
for test in range(tests):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [[-1, -1]] * n
	for i in range(2 * n):
		b[a[i] - 1] = [i, a[i]]
	b.sort()
	print(' '.join([str(i[1]) for i in b]))


try:
	t = int(input())
	while t:
		t = t - 1
		n = int(input())
		arr = list(map(int, input().split()))
		arr1 = []
		for x in arr:
			if x in arr1:
				continue
			else:
				print(x, end=' ')
				arr1.append(x)
except:
	pass


for _ in range(int(input())):
	n = int(input())
	s = [int(x) for x in input().split()]
	dic = {}
	a = []
	for i in s:
		if i in dic and dic[i] != 0:
			dic[i] = 1
		elif i not in dic:
			a.append(i)
			dic[i] = 1
		else:
			dic[i] = 0
			a.append(i)
	a = ' '.join([str(x) for x in a])
	print(a)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = intIn()
while t > 0:
	t -= 1
	n = intIn()
	a = listIn()
	ans = []
	di = defaultdict(int)
	cnt = 0
	for i in range(2 * n):
		if di[a[i]] == 0:
			cnt += 1
			di[a[i]] += 1
			ans.append(a[i])
		if cnt == n:
			break
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split()
	l = []
	for char in s:
		if char not in l:
			l.append(char)
	for c in l:
		print(c, end=' ')
	print()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(range(1, n + 1))
	s = ''
	for x in a:
		if b[x - 1] != 0:
			s += str(x) + ' '
			b[x - 1] = 0
	print(s[:-1])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	visited = [arr[0]]
	for i in range(1, len(arr)):
		if arr[i] not in visited:
			visited.append(arr[i])
	print(*visited)


import os
is_dev = 'vscode' in os.environ
if is_dev:
	inF = open('in.txt', 'r')
	outF = open('out.txt', 'w')

def ins(r):
	return list(map(int, r.split(' ')))

def inputT():
	if is_dev:
		return inF.readline()
	else:
		return input()

def printT(data):
	if is_dev:
		return outF.write(data + '\n')
	else:
		return print(data)
for _ in range(int(inputT())):
	n = int(inputT())
	x = ins(inputT())
	arr = set(range(1, n + 1))
	res = []
	for i in x:
		if i in arr:
			res.append(i)
			arr.remove(i)
	printT(' '.join(map(str, res)))
if is_dev:
	print(open('out.txt', 'r') == open('outactual.txt', 'r'))


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().strip().split()))
	ans = []
	for i in lst:
		if i not in ans:
			ans.append(i)
	print(*ans)


n = int(input())
f = []
g = []
h = []

def P(x, y):
	o = []
	for l in range(2 * y):
		if o.count(x[l]) > 0:
			continue
		else:
			o.append(x[l])
	u = ''
	m = False
	for i in o:
		if m:
			u = u + ' ' + i + ' '
		else:
			u = i
		m = True
	return u
for i in range(n):
	k = int(input())
	f.append(k)
	s = ''
	s = input().split()
	g.append(s)
for i in range(n):
	print(P(g[i], int(f[i])))


t = int(input())
while t > 0:
	n = int(input())
	s = input().split()
	lst = []
	for i in s:
		if i not in lst:
			lst.append(i)
	for i in range(len(lst)):
		print(lst[i], end='')
		if i != len(lst) - 1:
			print(' ', end='')
	print('\n', end='')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	(l1, p) = ([], [])
	l1 = list(map(int, input().split()))
	for i in l1:
		if i not in p:
			p.append(i)
			print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	temp = []
	while len(p) != 0:
		variable = p[0]
		temp.append(variable)
		p = list(filter(lambda x: x != variable, p))
	print(*temp, end=' ')


for i in range(int(input())):
	n = int(input())
	l = list(input().split())
	check = []
	for i in range(len(l)):
		if l[i] not in check:
			check.append(l[i])
	s = ' '.join(check)
	print(s)


for i in range(int(input())):
	dic = {}
	n = int(input())
	lis = list(map(int, input().split()))
	i = 0
	while i < len(lis):
		if lis[i] not in dic:
			dic[lis[i]] = 0
		dic[lis[i]] += 1
		i += 1
	for i in dic:
		print(i, end=' ')
	print()


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
mod = 10 ** 9 + 7
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	max_so_far = -sys.maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0, size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i + 1
	return (max_so_far, start, end)

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] >= arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def solve():
	n = int(input())
	arr = list_input()
	ans = []
	for i in range(2 * n):
		if not arr[i] in ans:
			ans.append(arr[i])
	print(*ans)
t = 1
t = int(input())
for _ in range(t):
	solve()


import collections
t = int(input())
for i in range(t):
	n = int(input())
	vec = list(map(int, input().split()))
	coleccion = collections.OrderedDict.fromkeys(vec)
	for (k, v) in coleccion.items():
		print(k, '', end='')
	print('')


def solve():
	N = int(input())
	a = list(map(int, input().split()))
	seen = [False] * (N + 1)
	ans = []
	for i in reversed(range(2 * N)):
		if seen[a[i]] == False:
			ans.append(a[i])
			seen[a[i]] = True
	print(*ans[::-1])
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	a = [0] * (n + 1)
	for j in range(len(l)):
		if a[l[j]] == 0:
			print(l[j], end=' ')
			a[l[j]] = 1
	print()


t = int(input())
f = []
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	f.append(' '.join(map(str, list(dict.fromkeys(l)))))
print(*f, sep='\n')


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	n = inp()
	a = inpl()
	res = []
	cnt = 0
	se = set()
	for x in a:
		if x in se:
			continue
		se.add(x)
		cnt += 1
		res.append(x)
	print(*res)


T = int(input())
for _ in range(T):
	N = int(input())
	x = list(map(int, input().strip().split()))
	set_x = [0] * (N + 1)
	out = str(x[0])
	out_count = 1
	set_x[x[0]] = -1
	for i in x:
		if set_x[i] == 0:
			out += ' ' + str(i)
			set_x[i] = -1
			out_count += 1
	print(out)


import math
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input('').split()))
	occur = dict()
	ans = []
	for i in A:
		if i not in occur.keys():
			ans.append(i)
		occur[i] = True
	print(*ans)


a = int(input())
for i in range(a):
	b = int(input())
	c = map(int, input().split())
	d = []
	for i in c:
		if i not in d:
			print(i, end=' ')
			d.append(i)
	print('')


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:2 * n]
	s = set()
	for i in range(2 * n):
		if a[i] in s:
			continue
		print(a[i], end=' ')
		s.add(a[i])
	print()


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for x in input().split()]

def fi():
	return int(input())

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')
t = fi()
while t > 0:
	t -= 1
	n = fi()
	a = li()
	d = {}
	r = []
	for i in range(2 * n):
		if a[i] not in d:
			d[a[i]] = 1
			r.append([i, a[i]])
	r.sort()
	for i in r:
		print(i[1], end=' ')
	print()


I = input

def main():
	for _ in range(int(I())):
		n = int(I())
		arr = list(map(int, I().split()))
		a = list()
		for x in arr:
			if not x in a:
				a.append(x)
		print(*a)
main()


def solve():
	x = int(input())
	s = list(map(int, input().split()))
	dc = {}
	for n in s:
		if n not in dc:
			print(n, end=' ')
			dc[n] = 1
	print()
for _ in range(int(input())):
	solve()


t = int(input())
while t:
	n = int(input())
	a = input().split()
	a = list(map(int, a))
	cnt = [0 for i in range(n + 1)]
	ans = []
	for i in range(2 * n):
		cnt[a[i]] += 1
		if cnt[a[i]] == 2:
			ans.append(a[i])
	for x in ans:
		print(x, end=' ')
	print()
	t -= 1


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = set()
	p = []
	for i in a:
		if i not in res:
			res.add(i)
			p.append(i)
	print(*p)


def read_int():
	return int(input().strip())

def read_ints():
	return list(map(int, input().strip().split(' ')))

def solve():
	n = read_int()
	answer = []
	seen = [False] * (n + 1)
	for a in read_ints():
		if not seen[a]:
			answer.append(a)
			seen[a] = True
	return ' '.join(map(str, answer))
T = read_int()
for _ in range(T):
	print(solve())


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ord1 = []
	j = 0
	while len(ord1) < n:
		if l[j] not in ord1:
			ord1.append(l[j])
		j += 1
	print(*ord1)


def ans(l):
	x = list(dict.fromkeys(l))
	for i in x:
		print(i, end=' ')
	print()
t = int(input())
while t > 0:
	a = int(input())
	l = list(map(int, input().split()))
	ans(l)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	dic = {}
	a1 = []
	a2 = []
	for i in range(2 * n):
		if ar[i] in dic:
			a2.append(ar[i])
		else:
			a1.append(ar[i])
			dic[ar[i]] = 1
	for i in a1:
		print(i, end=' ')
	print('')


for i in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	c = []
	for i in p:
		if i not in c:
			c += [i]
			print(i, end=' ')
	print()


loopcount = int(input())
for loop in range(loopcount):
	a = int(input())
	x = input()
	x = x.split(' ')
	x = list(map(int, x))
	output = []
	for i in x:
		if i not in output:
			output.append(i)
	print(' '.join(map(str, output)))


def get_orig_seq(perm: [int]) -> [int]:
	orig = []
	seen = {}
	for digit in perm:
		if digit not in seen:
			orig.append(digit)
			seen[digit] = 1
	return orig
for i in range(int(input().strip())):
	n = int(input().strip())
	perm = [int(ch) for ch in input().strip().split()]
	print(' '.join([str(num) for num in get_orig_seq(perm)]))


import sys
input = sys.stdin.readline
Q = int(input())
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	t = set()
	ans = []
	for a in A:
		if not a in t:
			ans.append(a)
		t.add(a)
	print(*ans)


for i in range(int(input())):
	l = []
	n = int(input())
	k = list(map(int, input().split()))
	for i in k:
		if i not in l:
			l.append(i)
	print(*l)


from collections import defaultdict as dd
for _ in range(int(input())):
	n = int(input())
	l = []
	m = dd(int)
	lst = list(map(int, input().split()))
	for i in range(2 * n):
		if m.get(lst[i], 0) == 0:
			m[lst[i]] += 1
	for i in m.keys():
		print(i, end=' ')
	print('')


n = int(input())
for i in range(n):
	input()
	sequence = input().split()
	out = []
	for num in sequence:
		if num not in out:
			out.append(num)
	print(' '.join(out))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	used = set()
	for i in a:
		if not i in used:
			ans += [i]
			used.add(i)
	print(*ans)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	arr2 = []
	for i in range(2 * n):
		if arr[i] not in arr2:
			arr2.append(arr[i])
	for i in range(n):
		print(arr2[i], end=' ')
	print('\n')
	t = t - 1


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	d = {}
	ans = []
	for i in range(2 * n):
		if a[i] not in d:
			d[a[i]] = 1
			ans += [a[i]]
	print(*ans)


test_case = int(input())
for i in range(test_case):
	n = int(input())
	ele = list(map(int, input().split()))
	p1 = []
	for i in ele:
		if len(p1) == n:
			print(' '.join(map(str, p1)))
			break
		if i not in p1:
			p1.append(i)


def fun(l):
	s = set()
	k = []
	for i in l:
		if i not in s:
			s.add(i)
			k.append(i)
	h = list(map(str, k))
	return ' '.join(h)
n = int(input())
for i in range(n):
	a = int(input())
	l = list(map(int, input().split()))
	print(fun(l))


from sys import stdin

def main():
	l = stdin.read().splitlines()[2::2]
	for (i, s) in enumerate(l):
		(f, r) = ([True] * 51, [])
		for x in map(int, s.split()):
			if f[x]:
				f[x] = False
				r.append(x)
		l[i] = ' '.join(map(str, r))
	print('\n'.join(l))
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = {}
	for i in l:
		if i not in s:
			print(i, end=' ')
			s[i] = 1
		else:
			s[i] += 1
	print()


import itertools

def main():
	(n,) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	r = [0] * n
	for x in a:
		r[x - 1] += 1
		if r[x - 1] == 2:
			print(x, end=' ')
	print()
	return
for _ in range(int(input())):
	main()


def main():
	t = Iint()
	for _ in range(t):
		n = Iint()
		a = Ilist()
		ans = [0] * n
		nums = set()
		i = 0
		for ai in a:
			if ai not in nums:
				nums.add(ai)
				ans[i] = ai
				i += 1
		Plist(ans)
FIO = 1

def I():
	return input()

def Iint():
	return int(input())

def Ilist():
	return list(map(int, input().split()))

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
en = enumerate
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import sys
	import os
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


Q = int(input())
for _ in range(Q):
	n = int(input())
	a = [int(i) for i in input().split()]
	ar = [0] * (n + 1)
	for i in a:
		if ar[i] == 0:
			ar[i] = 1
			print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = [i for i in input().split()]
	c = []
	for i in a:
		if i not in c:
			c.append(i)
			if len(c) == n:
				break
	print(' '.join(c))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list()
	for x in a:
		if (x in b) == 0:
			print(x, end=' ')
			b.append(x)
	print()


for i in range(int(input())):
	n = input()
	arr = input().split()
	ans = []
	for k in arr:
		if k not in ans:
			ans.append(k)
		if len(ans) == int(n):
			break
	print(' '.join(ans))


t = int(input())
a = []
b = []
res = []
for i in range(t):
	a.append([])
	b.append(int(input()))
	a[i] = [int(a[i]) for a[i] in input().split()]
for i in range(t):
	for j in range(1, b[i] + 1):
		a[i].remove(j)
	res.append(a[i])
for i in range(t):
	for j in range(b[i]):
		print(res[i][j], end=' ')
	print(' ')


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
testCases = int(input())
answers = []
for _ in range(testCases):
	n = int(input())
	arr = input_split()
	found = [False for i in range(n + 1)]
	ans = []
	for a in arr:
		if not found[a]:
			ans.append(a)
		found[a] = True
	answers.append(ans)
for ans in answers:
	print(*ans, sep=' ')


import collections

def solve(arr):
	d = collections.OrderedDict()
	for i in arr:
		if i not in d:
			d[i] = 1
	for i in d.keys():
		print(i, end=' ')
	print()

def main():
	t = int(input())
	while t > 0:
		n = int(input())
		arr = [int(x) for x in input().split()]
		solve(arr)
		t -= 1
main()


t = int(input())
for i in range(0, t):
	n = int(input())
	list1 = list(map(int, input().split()))
	mp = set()
	for i in list1:
		if i not in mp:
			mp.add(i)
			print(i, end=' ')


n = int(input())
for i in range(n):
	x = int(input())
	q = list(map(int, input().split()))
	r = []
	for i in q:
		if i not in r:
			r.append(i)
	print(*r)


t = int(input())
for _ in range(t):
	n = int(input())
	v = list(map(int, input().split()))
	l = []
	for e in v:
		if e not in l:
			l.append(e)
	for e in l:
		print(e, end=' ')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	l.append(a[0])
	for i in range(1, len(a)):
		x = a[i]
		if l.count(x) == 0:
			l.append(x)
	if len(l) == n:
		print(*l)


import sys
input = sys.stdin.buffer.readline

def solution():
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		d = {}
		a = []
		for i in range(len(l)):
			if d.get(l[i], 0) == 0:
				a.append(l[i])
				d[l[i]] = 1
		print(*a)
solution()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	c = Counter(l)
	ans = []
	for i in c.keys():
		ans += [i] * (c[i] // 2)
	print(*ans)


for i in range(int(input())):
	n = int(input())
	e = set()
	s = list()
	for x in list(map(int, input().split())):
		if x not in e:
			e.add(x)
			s.append(x)
	print(*s)


t = int(input())
for i in range(t):
	n = int(input())
	y = [int(y) for y in input().split()]
	s = []
	for i in y:
		if i in s:
			continue
		else:
			s.append(i)
	for i in s:
		print(int(i))


for i in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	test = [0] * n
	res = []
	for e in ar:
		if test[e - 1] == 1:
			continue
		else:
			res.append(e)
			test[e - 1] = 1
	print(*res)


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	n = iinput()
	p = linput()
	l = []
	ls = set()
	for e in p:
		if e not in ls:
			l.append(e)
			ls.add(e)
	print(*l)


from collections import Counter

def check(s):
	return list(Counter(s))
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	ans = check(s)
	print(*ans)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = []
	for i in arr:
		if i not in d:
			d.append(i)
			print(i, end=' ')
	print()


w = int(input())
a = []
b = []
for i in range(0, w):
	q = int(input())
	p = input().split()
	a.append(p)
	b.append(q)
for j in range(0, w):
	r = a[j]
	res = [i for (n, i) in enumerate(r) if i not in r[:n]]
	print(*res)


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	dic = {}
	for val in p:
		dic[val] = val
	print(' '.join(map(str, list(dic.keys()))))


def solve(a, n):
	z = dict(((el, 0) for el in range(1, n + 1)))
	ans = []
	for i in a:
		if z[i] == 0:
			ans.append(i)
			z[i] += 1
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(*solve(a, n))


T = int(input())
for i in range(T):
	arr = []
	j = 0
	n = int(input())
	ip = input()
	a = ip.split()
	for p in range(len(a)):
		a[p] = int(a[p])
	while len(arr) != n:
		if a[j] in arr:
			pass
		else:
			arr.append(a[j])
		j += 1
	for j in arr:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = []
	for i in range(2 * n):
		if arr[i] not in brr:
			print(arr[i], end=' ')
			brr.append(arr[i])
	print()


t = int(input())
for i in range(t):
	l = int(input())
	li = list(map(int, input().split()))
	ans = []
	pri = ''
	for i in range(2 * l):
		if li[i] not in ans:
			ans += [li[i]]
			pri += str(li[i]) + ' '
	print(pri)


t = int(input())
for i in range(t):
	b = int(input())
	a = list(map(int, input().split()))
	ans = []
	for j in a:
		if j in ans:
			continue
		else:
			ans.append(j)
	for j in ans:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	d = dict()
	for i in l:
		d[l.index(i)] = i
	d = {k: d[k] for k in sorted(d)}
	for (i, j) in d.items():
		print(j, end=' ')
	print()


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		s = set()
		l = []
		for i in a:
			if i not in s:
				l.append(i)
				s.add(i)
		print(*l)
main()


t = int(input())
for i in range(t):
	n = int(input())
	temp = input()
	temp = temp.split()
	a = []
	for k in range(2 * n):
		if temp[k] not in a:
			a.append(temp[k])
	for ele in a:
		print(ele, end=' ')
	print('')


def solve(A, n):
	s = set()
	half = n // 2
	res = []
	for x in A:
		if x not in s:
			s.add(x)
			res.append(str(x))
	return ' '.join(res)
res = []
t = int(input())
while t:
	n = int(input())
	arr = input().split(' ')
	A = [int(n) for n in arr]
	res.append(solve(A, n))
	t -= 1
for r in res:
	print(r)


def solve():
	n = int(input())
	visited = set({})
	ans = []
	V = list(map(int, input().split()))
	for v in V:
		if v not in visited:
			ans.append(v)
			visited.add(v)
	print(*ans)
t = int(input())
while t > 0:
	t -= 1
	solve()


t = int(input())
while t != 0:
	n = int(input())
	ar = list(map(int, input().split()))
	mark = [0] * (n + 1)
	for i in range(0, len(ar)):
		if mark[ar[i]] == 0:
			print(ar[i], end=' ')
		mark[ar[i]] += 1
	print('')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = [set(), set()]
	order = [[], []]
	for i in range(2 * n):
		if a[i] in ans[0]:
			order[1].append(a[i])
			ans[1].add(a[i])
		else:
			order[0].append(a[i])
			ans[0].add(a[i])
	print(*order[0])


for i in range(int(input())):
	n = int(input())
	s = [int(a) for a in input().split()]
	a = list()
	for g in s:
		if not g in a:
			a.append(g)
	for g in a:
		print(g, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	y = []
	for i in a:
		if i in s:
			y.append(str(i))
			s.remove(i)
	print(' '.join(y))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def solve(test):
	seen = set()
	ans = []
	for x in test:
		if x in seen:
			seen.remove(x)
		else:
			ans.append(x)
			seen.add(x)
	for a in ans:
		print(a, end=' ')
	print()
T = inp()
tests = []
for _ in range(T):
	inp()
	tests.append(inlt())
for test in tests:
	solve(test)


import sys
input = sys.stdin.readline
from collections import *
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	s = set()
	for ai in a:
		if ai not in s:
			ans.append(ai)
			s.add(ai)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	c = set()
	a = [0] * n
	i = 0
	for x in input().split():
		if x not in c:
			a[i] = x
			i += 1
			c.add(x)
	print(' '.join(a))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	res = []
	for i in range(2 * n):
		if len(res) == n:
			break
		if l[i] not in res:
			res.append(l[i])
			print(l[i], end=' ')
	print()


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A):
	seen = set()
	ans = []
	for x in A:
		if x not in seen:
			ans.append(x)
			seen.add(x)
	return ' '.join(map(str, ans))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list()
	for c in a:
		if c not in b:
			b += [c]
	print(*b)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def Gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def minimum_integer_not_in_list(a):
	b = max(a)
	if b < 1:
		return 1
	A = set(a)
	B = set(range(1, b + 1))
	D = B - A
	if len(D) == 0:
		return b + 1
	else:
		return min(D)

def solution():
	for i in range(Int()):
		n = Int()
		a = List()
		p = list(set(a))
		o = list(set(a))
		l = []
		for i in range(len(a)):
			if a[i] in o:
				l.append(a[i])
				o.remove(a[i])
		print(*l)
solution()


def solve(n, a):
	answ = {}
	for i in a:
		if answ.get(i, -1) == -1:
			answ[i] = None
	print(*answ.keys())
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	solve(n, a)


for _ in range(int(input())):
	answer = []
	pres = int(input())
	helper = list(map(int, input().split()))
	for i in helper:
		if i not in answer:
			answer.append(i)
	print(*answer)


def program():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	s = set()
	for x in arr:
		if x in s:
			s.remove(x)
		else:
			s.add(x)
			ans.append(x)
	for x in ans:
		print(x, end=' ')
	print()
for i in range(int(input())):
	program()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	permutation = list(dict.fromkeys(l).keys())
	print(' '.join([str(i) for i in permutation]))


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr1 = []
	for i in range(2 * n):
		if arr[i] not in arr1:
			arr1.append(arr[i])
	for i in range(len(arr1)):
		print(arr1[i], end=' ')
	print('')


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().strip().split()))
	seen = [0] * n
	res = []
	for (i, elem) in enumerate(a):
		if seen[elem - 1] == 0:
			seen[elem - 1] = 1
			res.append(elem)
	print(' '.join(map(str, res)))


num = int(input())
for i in range(num):
	lenz = input()
	arr = input()
	arr = arr.split(' ')
	res = []
	for j in range(len(arr)):
		if arr[j] not in res:
			res.append(arr[j])
	print(' '.join(res))


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	m = I()
	for i in range(1, n + 1):
		m.remove(i)
	for i in range(n):
		print(m[i], end=' ')
	print()


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	set_a = set()
	result = []
	for (i, ai) in enumerate(a):
		if ai not in set_a:
			result.append(ai)
			set_a.add(ai)
	print(*result)
	return 0

def main():
	t = int(input())
	for _ in range(t):
		solve()
	return 0
main()


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	res = []
	for i in a:
		if i not in res:
			res.append(i)
	for m in res:
		print(m, end=' ')


for _ in range(int(input())):
	n = int(input())
	sett = set([])
	a = list(map(int, input().split()))
	l = []
	for i in a:
		if len(l) == n:
			break
		if i in l:
			continue
		else:
			l.append(i)
	for j in l:
		print(j, end=' ')
	print()


a = int(input())
for i in range(a):
	stri = ''
	b = int(input())
	c = input()
	d = [int(x) for x in c.split()]
	for j in range(b):
		e = d.index(j + 1)
		d.pop(e)
	for k in range(b):
		stri = stri + str(d[k]) + ' '
	print(stri)


c = int(input())
for j in range(c):
	n = int(input())
	l = list(map(int, input().split()))
	d = list(dict.fromkeys(l))
	for i in d:
		if i in l:
			print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a = []
	for i in range(0, len(arr)):
		for j in range(i + 1, len(arr)):
			if arr[i] == arr[j]:
				a.append(arr[j])
	print(*a)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	l2 = []
	while l != []:
		l1.append(l.pop(0))
		for i in range(0, 2 * n):
			if l1[-1] == l[i]:
				l.pop(i)
				break
	print(*l1, sep=' ')


for case in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	p = []
	seen = set()
	for x in a:
		if x not in seen:
			p.append(x)
			seen.add(x)
	print(' '.join((str(x) for x in p)))


n = int(input())
while n:
	n -= 1
	t = int(input())
	a = list(map(int, input().split(' ')))
	d = {}
	for i in range(1, t + 1):
		d[i] = 0
	temp = []
	for i in a:
		if d[i] == 0:
			d[i] = 1
			print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	x = set()
	ans = []
	length = len(x)
	for i in range(n * 2):
		x.add(arr[i])
		if len(x) > length:
			ans.append(arr[i])
		length = len(x)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(dict.fromkeys(map(int, input().split())))
	for j in range(n):
		print(str(a[j]), end=' ')
	print(end='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	hash = {}
	for i in range(2 * n):
		if arr[i] not in hash:
			hash[arr[i]] = 'T'
	for (keys, values) in hash.items():
		print(keys, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	f = []
	for e in p:
		if e not in f:
			f.append(e)
	print(*f)


test = int(input())
length = []
string = []
for t in range(test):
	length.append(int(input()))
	string.append(input())
for l in string:
	nums = l.split()
	fin = []
	for alpha in nums:
		if int(alpha) not in fin:
			fin.append(int(alpha))
			print(alpha + ' ', end='')
	print('')


def main(arr):
	new = arr
	checked = []
	for i in range(len(arr)):
		if not arr[i] in checked:
			checked.append(arr[i])
	return checked
n = int(input())
inp = []
for i in range(2 * n):
	new_st = input()
	new_lst = new_st.split(' ')
	inp.append(main(new_lst))
del inp[::2]
for i in range(len(inp)):
	print(' '.join(inp[i]))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	lst = []
	for i in a:
		if i in lst:
			continue
		else:
			lst.append(i)
	print(*lst, sep=' ')


import os
import operator
import sys
from io import BytesIO, IOBase

def inar():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = inar()
		dic = {}
		res = []
		for i in range(2 * n):
			if arr[i] not in dic:
				dic[arr[i]] = 1
				res.append(arr[i])
		print(*res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	d = {}
	ans = []
	for i in a:
		if i not in d:
			ans.append(i)
		d[i] = True
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	res = list()
	for i in a:
		if i not in res:
			res.append(i)
	print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(k) for k in input().split()]
	indices = [0] * n
	p = []
	for val in a:
		if indices[val - 1] == 0:
			indices[val - 1] = 1
			p.append(val)
	for val in p:
		print(val, end=' ')


test = int(input())

def solve():
	n = int(input())
	arr = [int(i) for i in input().split()]
	a = []
	for i in range(len(arr)):
		if arr[i] not in a:
			a.append(arr[i])
	for i in range(len(a)):
		print(a[i], end=' ')
	print()
while test:
	solve()
	test -= 1


import sys, math

def ii():
	return int(input())

def mii():
	return map(int, input().split())

def lmii():
	return list(mii())

def main():
	for _ in range(ii()):
		n = ii()
		d = lmii()
		vis = [0] * n
		ans = []
		for i in range(2 * n):
			if vis[d[i] - 1] == 0:
				ans.append(d[i])
				vis[d[i] - 1] = 1
		print(*ans)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	freq = [2] * n
	for i in range(2 * n):
		if freq[a[i] - 1] == 2:
			print(a[i], end=' ')
			freq[a[i] - 1] -= 1
	print()


def func(t):
	for i in range(t):
		ans = []
		l2 = []
		n = int(input())
		l = list(map(int, input().split()))
		for i in l:
			if i not in ans and i not in l2:
				ans.append(i)
			else:
				l2.append(i)
		print(*ans)
t = int(input())
func(t)


test = int(input())
for _ in range(test):
	n = int(input())
	seen = set()
	arr = list(map(int, input().split()))
	ans = []
	for i in arr:
		if i not in seen:
			ans.append(i)
			seen.add(i)
	print(*ans)


from functools import reduce
for _ in range(int(input())):
	n = int(input())
	a = []
	b = 0
	c = set()
	for i in input().split():
		if i in c:
			pass
		else:
			a.append(i)
			b += 1
			c.add(i)
	print(' '.join(a))


n = int(input())
a = []
for i in range(n):
	k = int(input())
	a.append(list(map(int, input().split())))
for i in range(n):
	c = []
	for j in range(2 * max(a[i])):
		if a[i][j] not in c:
			c.append(a[i][j])
	print(*c)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p1 = []
	for i in range(2 * n):
		if a[i] in p1:
			continue
		else:
			p1.append(a[i])
	print(*p1, sep=' ')


import sys
import math
from sys import stdin
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	p = []
	dic = dict()
	for i in arr:
		if i not in dic:
			dic[i] = 1
			p.append(i)
	print(*p)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	ans = []
	for i in a:
		if i in s:
			continue
		s.add(i)
		ans.append(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = []
	d = {}
	for i in a:
		if i not in d:
			res.append(i)
			d[i] = 1
		else:
			d[i] = 1
	print(*res, sep=' ')


for _ in range(int(input())):
	N = int(input())
	seq = list(map(int, input().split()))
	dicti = {}
	res = []
	for i in range(2 * N):
		if not dicti.get(seq[i], 0):
			dicti[seq[i]] = 1
			res.append(seq[i])
	print(*res)


for _ in range(int(input())):
	l = int(input())
	a = list(map(int, input().split()))
	r = []
	for i in a:
		if i in r:
			continue
		else:
			r.append(i)
	print(*r)


t = int(input())
for t_i in range(t):
	n = int(input())
	a = map(int, input().split())
	values = set()
	permutation = []
	for x in a:
		if x not in values:
			values.add(x)
			permutation.append(x)
	print(*permutation, sep=' ')


toint = lambda x: int(x)

def get_line_int():
	line = input().strip().split(' ')
	line = list(map(toint, line))
	return line

def print_line_of_list(lst):
	for i in range(len(lst) - 1):
		print(lst[i], end=' ')
	print(lst[-1])
t = int(input())
for ___ in range(t):
	n = int(input())
	p1 = [0] * n
	p2 = [0] * n
	per1 = []
	per2 = []
	l = get_line_int()
	for num in l:
		if p1[num - 1] == 0:
			p1[num - 1] = 1
			per1.append(num)
		else:
			p2[num - 1] = 1
			per2.append(num)
	print_line_of_list(per1)


for _ in range(int(input())):
	n = int(input())
	a = map(int, input().split(' '))
	arr = [0] * (n + 1)
	ans = []
	num = 0
	for i in a:
		if arr[i] == 0:
			arr[i] = 1
			ans.append(i)
			num += 1
		if num > n:
			break
	print(*ans)


n = int(input())
for _ in range(n):
	length = int(input())
	seq = [int(i) for i in input().split(' ')]
	res = []
	for ele in seq:
		if ele not in res:
			res.append(ele)
	print(*res)


t = int(input())
while t > 0:
	n = int(input())
	p = list(map(int, input().split()))
	visited = []
	for i in range(n):
		visited.append(False)
	permutation = []
	for num in p:
		if not visited[num - 1]:
			permutation.append(str(num))
			visited[num - 1] = True
	print(' '.join(permutation))
	t -= 1


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(n):
	tc = []
	ans = {}
	d = 2
	while d * d <= n:
		if n % d == 0:
			tc.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		tc.append(n)
	for i in tc:
		ans[i] = ans.get(i, 0) + 1
	return ans
for _ in range(int(input())):
	(n, a) = na()
	d = {}
	for i in range(1, n + 1):
		d[i] = 0
	ans = []
	for i in a:
		if d[i] == 0:
			d[i] += 1
		else:
			ans.append(i)
	print(*ans)


def sol():
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = [int(i) for i in input().split()]
		B = [A[0]]
		j = 0
		for i in range(1, 2 * n):
			if A[i] not in B:
				B.append(A[i])
				j += 1
		print(*B)
sol()


for _ in range(int(input())):
	n = int(input())
	listi = list(map(int, input().split()))
	result = []
	for i in listi:
		if i not in result:
			result.append(i)
	for i in result:
		print(i, end=' ')
	print()


t = int(input())
i = 1
while i <= t:
	ans = list()
	sample = list()
	n = int(input())
	w = input()
	p = w.split()
	for j in p:
		sample.append(int(j))
	ans.append(sample[0])
	for item in sample:
		if item not in ans:
			ans.append(item)
	for q in ans:
		print(q, end=' ')
	print('')
	i += 1


for _ in range(int(input())):
	input()
	n = list(map(int, input().split()))
	ans = []
	for i in n:
		if i not in ans:
			ans.append(i)
	print(*ans)


tt = int(input())
while tt:
	tt -= 1
	n = int(input())
	l = list(map(int, input().split()))
	r = []
	for i in l:
		if i not in r:
			r.append(i)
	print(' '.join(map(str, r)))


import collections
t = int(input())
for i in range(t):
	n = int(input())
	vec = list(map(int, input().split()))
	coleccion = collections.OrderedDict.fromkeys(vec)
	vec_final = []
	for (k, v) in coleccion.items():
		vec_final.append(k)
	i = 1
	for elementos in vec_final:
		print(elementos, end='')
		if i != len(vec_final):
			print(' ', end='')
		i += 1
	print()


t = int(input())
ret = []
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = []
	for e in l:
		if e not in s:
			s.append(e)
		else:
			continue
	ret.append(' '.join([str(x) for x in s]))
sol = '\n'.join(ret)
print(sol)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	s = list()
	for i in li:
		if i not in s:
			s.append(i)
	print(*s)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	lst = list(set(arr))
	lst.sort(key=lambda x: arr.index(x))
	print(*lst)


t = int(input())
for _ in range(t):
	n = int(input())
	B = []
	A = list(map(int, input().split()))
	for i in range(2 * n):
		if A[i] not in B:
			B.append(A[i])
	print(*B)


__MULTITEST = True

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	p1 = 0
	p2 = 1
	while a[p2] != a[p1]:
		p2 += 1
	check = [False] * (2 * n)
	ans = []
	while True:
		ans.append(a[p1])
		check[p1] = True
		check[p2] = True
		if len(ans) == n:
			break
		while check[p1]:
			p1 += 1
		p2 = max(p1, p2) + 1
		while a[p1] != a[p2]:
			p2 += 1
	print(*ans)
t = int(input()) if __MULTITEST else 1
for tt in range(t):
	solve()


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans

def product(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def maxpower(n, k):
	cnt = 0
	while n > 1:
		cnt += 1
		n //= k
	return cnt
from math import *
from collections import deque
max_steps = 100005
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	li = []
	for i in a:
		if i in li:
			continue
		else:
			li.append(i)
	print(*li)


size = int(input())
for x in range(size):
	out = ''
	unique = []
	length = int(input())
	nums = input().split()
	for j in range(length * 2):
		kyra = 1
		a = int(nums[j])
		if j == 0:
			unique.append(a)
		else:
			for k in range(len(unique)):
				if a == unique[k]:
					kyra = 0
			if kyra == 1:
				unique.append(a)
	for f in range(length):
		out += str(unique[f]) + ' '
	print(out)


num = int(input())
lst = []
for i in range(num):
	inp = int(input())
	words = input().split()
	counts = dict()
	lst1 = []
	for word in words:
		if word not in lst1:
			lst1.append(word)
	lst.append(lst1)
for i in lst:
	s = ''
	for j in i:
		s += j + ' '
	s.strip()
	print(s)


for _ in range(int(input())):
	t = int(input())
	l = list(map(int, input().split()))
	ul = []
	for x in l:
		if x not in ul:
			ul.append(x)
	for x in ul:
		print(x, end=' ')
	print()


for z in range(int(input())):
	n = int(input())
	s = set()
	a = []
	count = 0
	for i in input().split():
		if i not in s:
			a.append(i)
			s.add(i)
			count += 1
			if count == n:
				break
	print(*a)


import math

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		d[i] = 0
	ans = []
	for i in l:
		if d[i] == 0:
			ans.append(i)
			d[i] = 1
	for i in ans:
		print(i, end=' ')
	print()
t = 1
t = int(input())
while t > 0:
	t -= 1
	solve()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('out.txt', 'w')
except:
	pass
t = L()[0]
for _ in range(t):
	n = L()[0]
	A = L()
	arr = []
	s = set()
	for ele in A:
		if ele in s:
			continue
		arr.append(ele)
		s.add(ele)
	print(*arr)


def unique(sequence):
	seen = set()
	return [x for x in sequence if not (x in seen or seen.add(x))]
t = int(input())
for _ in range(t):
	n = int(input())
	x = [int(x) for x in input().split()]
	ans = unique(x)
	for i in range(n):
		print(ans[i], end=' ')
	print()


for t in range(int(input())):
	n = int(input())
	p = list(map(int, input().split(' ')))
	a = dict.fromkeys(p)
	for x in a:
		print(x, end=' ')
	print(' ')


import math
t = int(input())
while t > 0:
	t -= 1
	n = input()
	l = list(map(int, input().split(' ')))
	l2 = []
	for i in l:
		if i not in l2:
			l2.append(i)
			print(i, end=' ')


t = int(input())
for _ in range(t):
	t = int(input())
	x = input().split()
	mp = {}
	ans = ''
	for i in x:
		if i not in mp:
			mp[i] = 1
			ans += i + ' '
	print(ans[:-1])


def problem1():
	(x, y, z) = sorted(list(map(int, input().split())))
	if y != z:
		print('NO')
		return
	print('YES')
	print(y, x, x)

def problem2():
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	d = {}
	for i in s:
		d[i] = 0
	a = []
	for i in l:
		if d[i] == 0:
			a.append(i)
			d[i] += 1
	print(*a)
cases = int(input())
for _ in range(cases):
	problem2()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = input().split(' ')
	s = set([])
	p = []
	for a in arr:
		if a not in s:
			p.append(a)
			s.add(a)
	print(' '.join(p))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	n = II()
	aa = MI()
	fin = [False] * (n + 1)
	ans = []
	for a in aa:
		if fin[a]:
			continue
		ans.append(a)
		fin[a] = True
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	b = []
	a = [int(i) for i in input().split()]
	for i in range(len(a)):
		if a[i] not in b:
			b += [a[i]]
	for i in range(len(b)):
		print(b[i], end=' ')
	print()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = []
	r = i = 0
	while r < n:
		if a[i] not in d:
			r += 1
			d.append(a[i])
		i += 1
	print(*d)


from sys import stdin, stdout

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline()
for _ in range(ii()):
	l = ii()
	pre = [0] * (l + 1)
	l1 = li()
	last = 0
	for i in range(len(l1)):
		if pre[l1[i]] == 0:
			print(l1[i], end=' ')
			pre[l1[i]] = 1
	print('')


def finder(nums):
	ret = []
	mem = set()
	for num in nums:
		if not num in mem:
			ret.append(num)
			mem.add(num)
	return ret
n = int(input())
for i in range(n):
	_ = input()
	nums = input().split(' ')
	result = ' '.join(finder(nums))
	print(result)


def solution(a):
	p = 0
	z = []
	k = []
	for i in range(len(l)):
		if l[i] not in z:
			k.append(l[i])
			z.append(l[i])
	print(*k)
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	solution(l)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		if i in b:
			pass
		else:
			b.append(i)
	print(*b)


import sys
input = lambda : sys.stdin.readline().strip()
char = [chr(i) for i in range(97, 123)]
CHAR = [chr(i) for i in range(65, 91)]
mp = lambda : list(map(int, input().split()))
INT = lambda : int(input())
rn = lambda : range(INT())
from math import ceil, sqrt, factorial, gcd
for _ in rn():
	n = INT()
	l = set(mp())
	print(*l)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	s = set()
	ans = []
	for v in a:
		if v not in s:
			ans += [v]
			s.add(v)
	print(*ans)


def per(n):
	x = [int(i) for i in input().split()]
	dp = [False] * (n + 1)
	for i in x:
		if dp[i] == False:
			dp[i] = True
			print(i, end=' ')
	print()
testcase = int(input())
for i in range(testcase):
	per(int(input()))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	lst = []
	for j in range(0, 2 * n):
		if a[j] in lst:
			continue
		else:
			lst.append(a[j])
	for k in range(len(lst)):
		print(lst[k], end=' ')
	print()


t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().strip().split()))[:2 * n]
	res = []
	for i in a:
		if i not in res:
			res.append(i)
	for i in res:
		print(i, end=' ')
	print()
	t -= 1


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	n = stdint()
	arr = list(stdarr())
	res = []
	for i in arr:
		if i not in res:
			res.append(i)
	print(*res)


n = int(input())
for i in range(n):
	length = int(input())
	l = list(map(int, input().split()))
	res = []
	for i in range(len(l)):
		a = l[i]
		if a not in res:
			res.append(a)
	for x in res:
		print(x, end=' ')
	print()


n = int(input())
lastList = []
for i in range(n):
	mySet = set()
	myList = []
	l = int(input())
	a = list(map(int, input().split()))
	for j in range(2 * l):
		if a[j] not in mySet:
			mySet.add(a[j])
			myList.append(a[j])
	lastList.append(myList)
for elem in lastList:
	print(*elem)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	l = [0] * (n + 1)
	for i in a:
		if l[i] == 0:
			l[i] = 1
			print(i, end=' ')
		else:
			pass
	print()


import math
import datetime
import collections
import statistics
import itertools

def is_prime(num):
	for i in range(2, int(math.sqrt(num)) + 1):
		if num % i == 0:
			return False
	return True

def input_list():
	ll = list(map(int, input().split(' ')))
	return ll
tc = int(input())
for _ in range(tc):
	n = int(input())
	x = []
	arr = input_list()
	for i in arr:
		if i not in x:
			x.append(i)
	for i in x:
		print(i, end=' ')
	print(' ')


for s in [*open(0)][2::2]:
	print(*{*s.split()})


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	a = list(map(int, input().split()))
	ans = []
	lst = [0] * 2 * n
	for i in range(2 * n):
		if lst[a[i]] == 0:
			lst[a[i]] = 1
			print(a[i], end=' ')
	print('')


tests = int(input())
for _ in range(tests):
	len_rep = int(input())
	rep_list = list(map(int, input().split()))
	start_list = [rep_list[0]]
	for i in range(0, len(rep_list)):
		if rep_list[i] not in start_list:
			start_list.append(rep_list[i])
	print(*start_list)


for t in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	y = []
	for i in x:
		if str(i) in y:
			pass
		else:
			y += [str(i)]
	print(' '.join(y))


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def read(func=int):
	return map(func, input().split())
t = int(input())
for _ in range(t):
	input()
	l = list(read())
	a = []
	for i in l:
		if i not in a:
			print(i, end=' ')
			a.append(i)
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	tr = list(map(int, input().split()))
	lst = []
	lst.append(tr[0])
	for i in range(len(tr) - 1):
		if tr[i] != tr[i + 1] and tr[i + 1] not in lst:
			lst.append(tr[i + 1])
	print(*lst)


import math as mt
import sys, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : list(map(int, input().split()))
I = lambda : int(input())
from collections import defaultdict
t = I()
for _ in range(t):
	n = I()
	l = L()
	v = [0] * n
	a = []
	for i in range(2 * n):
		if v[l[i] - 1] == 0:
			a.append(l[i])
			v[l[i] - 1] = 1
	print(*a)


T = int(input())
for q in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		ok = False
		for j in b:
			if i == j:
				ok = True
				break
		if not ok:
			print(i, end=' ')
			b.append(i)
	print()


s = int(input())
for _ in range(s):
	n = int(input())
	a = list(map(int, input().split()))
	t = []
	for i in a:
		t.append(a.index(i))
	t = list(set(t))
	for i in t:
		print(a[i], end=' ')


t = int(input())
for i in range(t):
	n = int(input())
	m = list(map(int, input().split()))
	new = []
	for i in m:
		if i not in new:
			new.append(i)
	for i in range(len(new)):
		print(new[i], end=' ')


from sys import stdin, stdout
for i in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = [int(num) for num in stdin.readline().split()]
	ans = []
	for i in a:
		if i not in ans:
			ans.append(i)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	res = []
	for ele in lst:
		if ele not in res:
			res.append(ele)
	print(*res)


s = int(input())
for i in range(s):
	b = []
	l = int(input())
	a = [int(i) for i in input().split()]
	for k in a:
		if k not in b:
			b.append(k)
	for j in b:
		print(j, end=' ')


from collections import OrderedDict
for _ in range(int(input())):
	n = int(input())
	llist = list(map(int, input().split()))
	print(*list(OrderedDict.fromkeys(llist)))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	res = []
	f = 0
	for i in range(2 * n):
		if l[i] not in res:
			res.append(l[i])
			f += 1
		if f == n:
			break
	print(*res)


t = int(input())
for _ in range(t):
	n = int(input())

	def per_merg(n, l):
		s = set()
		list_1 = []
		for i in l:
			if i not in s:
				list_1.append(str(i))
			s.add(i)
		print(' '.join(list_1))
	l = list(map(int, input().split()))
	per_merg(n, l)


t = int(input())
for i in range(t):
	n = int(input())
	x = [int(x) for x in input().split()]
	b = []
	b.append(x[0])
	for j in range(2 * n):
		if x[j] in b:
			pass
		else:
			b.append(x[j])
	print(' '.join(map(str, b)))


a = int(input())
for i in range(a):
	x = int(input())
	b = list(map(int, input().split()))
	c = []
	for i in b:
		if i not in c:
			c.append(i)
	print(*c)


def solve():
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	d = []
	for i in arr:
		if i not in d:
			d.append(i)
	print(' '.join([str(x) for x in d]))
for i in range(int(input())):
	solve()


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	a = input().split()
	x = [0] * n
	y = []
	for i in range(0, 2 * n):
		a[i] = int(a[i])
	for i in range(0, 2 * n):
		if x[a[i] - 1] == 0:
			y.append(a[i])
			x[a[i] - 1] = x[a[i] - 1] + 1
	k = str(y[0])
	for i in range(1, n):
		k = k + ' ' + str(y[i])
	print(k)


t = int(input())
for i in range(0, t):
	n = int(input())
	arr = list(map(int, input().split()))
	result = []
	d = {}
	for j in range(0, n):
		d[j] = 0
	for j in range(0, 2 * n):
		if d[arr[j] - 1] == 0:
			d[arr[j] - 1] = 1
			result.append(arr[j])
	print(*result)


for ii in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	while p:
		x = p[0]
		print(x, end=' ')
		p.remove(x)
		p.remove(x)
	print()


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	N = int(stdin.readline())
	A = [int(x) for x in stdin.readline().split()]
	p1 = []
	selected = [False for i in range(N)]
	for i in range(2 * N):
		if not selected[A[i] - 1]:
			selected[A[i] - 1] = True
			p1.append(A[i])
	print(*p1)


def solve():
	n = int(input())
	array = list(map(int, input().split()))
	already = set()
	for i in range(2 * n):
		if array[i] not in already:
			print(array[i], end=' ')
			already.add(array[i])
	print()
t = int(input())
while t != 0:
	t -= 1
	solve()


def listMaker(lenList, arr):
	answer = []
	for element in arr:
		if element not in answer:
			answer.append(element)
		elif len(answer) == lenList:
			break
	return answer
test_cases = int(input())
for i in range(test_cases):
	lenList = int(input())
	arr = map(int, input().split())
	answer = listMaker(lenList, arr)
	for element in answer:
		print(element, end=' ')


from collections import defaultdict
for _ in range(int(input())):
	N = int(input())
	List = [int(x) for x in input().split()]
	Visited = defaultdict(bool)
	Ans = []
	for i in List:
		if Visited[i] == False:
			Ans.append(i)
			Visited[i] = True
	print(*Ans)


import sys

def remove_duplicates(lst):
	freq_table = {}
	for item in lst:
		if item not in freq_table:
			freq_table[item] = 1
		else:
			freq_table[item] += 1
	for item in freq_table:
		if freq_table[item] > 1:
			lst.remove(item)
	for x in lst:
		print(x, end=' ')
	print('\n')
n = sys.stdin.readline()
try:
	for i in range(int(n)):
		N = int(sys.stdin.readline())
		arr = [int(x) for x in sys.stdin.readline().split()]
		remove_duplicates(arr)
except ValueError as ve:
	print('')


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	new_string = []
	for j in s:
		if j not in new_string:
			new_string.append(j)
	print(*new_string, sep=' ')


T = int(input())
for t in range(T):
	n = int(input())
	li = list(map(int, input().split()))
	s = set()
	for i in range(2 * n):
		if li[i] not in s:
			s.add(li[i])
			print(li[i], end=' ')
	print()


for i in range(int(input())):
	a = []
	n = int(input())
	list1 = list(map(int, input().split()))
	s = list(set(list1))
	for j in list1:
		if j in s:
			s.remove(j)
			a.append(j)
			if len(s) == 0:
				break
	for j in a:
		print(j, end=' ')
	print()


n = int(input())
for i in range(n):
	a = int(input())
	b = [int(x) for x in input().split()]
	c = []
	for elem in b:
		if elem not in c:
			c.append(elem)
	for q in c:
		print(q, end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	l = []
	for ele in a:
		if ele not in s:
			l.append(ele)
			s.add(ele)
	for ele in l:
		print(ele, end=' ')
	print()


import os
from io import BytesIO, IOBase
import sys

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		vis = [False for i in range(n)]
		ans = []
		for i in range(n * 2):
			if not vis[a[i] - 1]:
				ans.append(a[i])
			vis[a[i] - 1] = True
		print(*ans)
	return
BUFSIZE = 1048576

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys, math
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from collections import deque, defaultdict
from copy import deepcopy
from math import ceil, floor, inf, sqrt, factorial, gcd, log2
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
for _ in range(ii1()):
	n = ii1()
	arr = iia()
	dp = [0] * (n + 1)
	ans = []
	for i in range(2 * n):
		if dp[arr[i]] == 0:
			ans.append(arr[i])
			dp[arr[i]] = 1
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	lists = list(map(int, input().split()))
	list1 = []
	list2 = []
	for i in lists:
		if i in list2:
			list1.append(i)
		else:
			list2.append(i)
	print(*list1)


t = int(input())
for i in range(t):
	n = int(input())
	num = list(map(int, input().split()))
	ans = []
	for i in range(len(num)):
		if num[i] not in ans:
			ans.append(num[i])
	print(*ans)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	hash = [0 for i in range(n + 1)]
	arr = [int(c) for c in input().split()]
	ans = [0 for i in range(n)]
	j = 0
	for i in range(2 * n):
		if hash[arr[i]] == 0:
			ans[j] = arr[i]
			j += 1
			hash[arr[i]] = 1
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	ans = []
	for i in num:
		if i not in ans:
			ans.append(i)
	for j in ans:
		print(j, end=' ')
	print()


t = int(input())
for _ in range(t):
	d = dict()
	a = int(input())
	arr = list(map(int, input().split()))
	res = []
	for i in arr:
		if i not in d:
			d[i] = 1
			res.append(i)
	print(*res)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	i = 0
	while len(ans) != n:
		if arr[i] not in ans:
			ans.append(arr[i])
		i = i + 1
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	n2 = []
	p = []
	a = input().split()
	for k in range(len(a)):
		n2.append(int(a[k]))
	for j in range(len(n2)):
		if n2[j] not in p:
			p.append(n2[j])
	temp = ''
	for d in range(len(p)):
		temp += str(p[d])
		if d != len(p) - 1:
			temp += ' '
	print(temp)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	dic = set()
	p = []
	for i in a:
		if i not in dic:
			dic.add(i)
			p.append(i)
	return p
T = int(input())
for i in range(T):
	a = solve()
	n = len(a)
	for i in range(n):
		if i == n - 1:
			print(a[i])
		else:
			print(a[i], end=' ')


import os, sys
from io import BytesIO, IOBase
from collections import Counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	z = []
	for t in y:
		if t not in z:
			z.append(t)
	print(*z)


n = int(input())
for i in range(n):
	res = []
	long = int(input())
	nums = list(map(int, input().split()))
	k = 0
	mark = 0
	for j in range(len(nums)):
		if mark == 1:
			mark = 0
			continue
		if not res:
			res.append(nums[j])
		elif res[k] != nums[j]:
			res.append(nums[j])
		elif res[k] == nums[j]:
			if k < len(res) - 1:
				k += 1
			elif j < len(nums) - 1:
				res.append(nums[j + 1])
				mark = 1
				k += 1
	for tem in res:
		print(tem, end=' ')


t = int(input())
from collections import Counter
for _ in range(t):
	n = int(input())
	inp = list(map(int, input().split()))
	c = Counter([])
	ans = []
	for item in inp:
		if c[item] == 0:
			ans.append(item)
			c[item] += 1
	for item in ans:
		print(item, end=' ')
	print(' ')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	result = [0] * n
	ans = ''
	for i in arr:
		if result[i - 1] == 0:
			result[i - 1] = 1
			ans += str(i) + ' '
		if sum(result) == n:
			break
	print(ans)


testcases = int(input())
for k in range(testcases):
	nums = int(input())
	ls = input().split(' ')
	ls = [int(i) for i in ls]
	nw = []
	for i in range(len(ls)):
		if not ls[i] in nw:
			nw += [ls[i]]
			nums -= 1
			if nums == 0:
				break
	s = ''
	for i in nw:
		s += f'{i} '
	print(s)


import sys
input = sys.stdin.readline

def getActual(arr):
	h = {}
	ans = []
	for ele in arr:
		if ele not in h:
			h[ele] = 1
			ans.append(ele)
	for ele in ans:
		print(ele, end=' ')
	print('')

def solution():
	n = int(input())
	arr = list(map(int, input().split()))
	getActual(arr)
t = int(input())
for i in range(0, t):
	solution()


total = int(input())
while total:
	n = int(input())
	l = [int(i) for i in input().split()]
	f = []
	for i in l:
		if i not in f:
			f.append(i)
	for j in f:
		print(j, end=' ')
	print()
	f.clear()
	total = total - 1


for _ in range(int(input())):
	n = int(input())
	li = [int(x) for x in input().split()]
	print(*list(set(li)))


import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

def calc(arr):
	ans = []
	for a in arr:
		if not a in ans:
			ans.append(a)
	return ans

def main():
	n = int(input())
	arr = []
	for _ in range(n):
		t = int(input())
		arr.append(list(map(int, input().split(' '))))
	for i in range(n):
		print(' '.join(map(str, calc(arr[i]))))
main()


answer = []

def filter_array(array):
	for i in range(0, len(array)):
		for j in range(i + 1, len(array)):
			if array[i] == array[j]:
				array[j] = None
	array = list(filter(None, array))
	return array
test = int(input())
for i in range(test):
	n = int(input())
	x = input().split()
	x = list(map(int, x))
	x = filter_array(x)
	answer.append(x)
for i in range(len(answer)):
	print(*answer[i])


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		s = str(input())
		s = s.split()
		for j in range(len(s)):
			s[j] = int(s[j])
		inn = list()
		ans = list()
		for j in s:
			if j not in ans:
				ans.append(j)
		out = ''
		for j in ans:
			out += str(j) + ' '
		print(out)
main()


import sys
import os

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def take_input():
	if os.environ.get('check'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
take_input()
for _ in range(int(input())):
	n = int(input())
	arr = int_array()
	b = []
	ans = []
	for i in range(len(arr)):
		if ans.count(arr[i]) == 0:
			ans.append(arr[i])
	print(*ans)


t = int(input())
for i in range(t):
	w = int(input())
	l = list(map(int, input().split()))
	x = []
	for k in l:
		if k in x:
			pass
		else:
			x.append(k)
	print(*x)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()
		x = []
		m = {}
		for i in a:
			if i not in m:
				x.append(i)
				m[i] = 1
		print(*x)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


t = int(input())
for q in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	p = []
	for i in a:
		if not i in p:
			p.append(i)
	print(*p)


testcases = int(input())
for test in range(testcases):
	n = int(input())
	l = list(map(int, input().strip().split(' ')))
	dicti = dict({})
	result = []
	for i in range(len(l)):
		if l[i] in dicti:
			pass
		else:
			dicti[l[i]] = True
			result.append(l[i])
			if len(result) == n:
				break
	for i in result:
		print(i, end=' ')
	print()


from sys import stdin, stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	n = ii1()
	arr = iia()
	d = {}
	for i in range(len(arr)):
		d.setdefault(arr[i], []).append(i)
	res = []
	for i in arr:
		if len(d[i]) == 1:
			res.append(i)
			d[i] = []
		else:
			d[i].pop(0)
	print(*res)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	arr = []
	s = set()
	for x in a:
		if x not in s:
			arr.append(x)
			s.add(x)
	print(*arr)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	dic = []
	for i in p:
		if i not in dic:
			dic.append(i)
	print(*dic)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = inp()
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	n = inp()
	a = inlt()
	ans = list()
	for i in range(2 * n):
		if a[i] != 0:
			ans.append(a[i])
			for j in range(i + 1, 2 * n):
				if a[j] == a[i]:
					a[j] = 0
					break
	print(' '.join(map(str, ans)))


from sys import stdin

def solve(n, arr):
	res = []
	for i in arr:
		if i not in res:
			res += [i]
	print(*res)
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().rstrip().split()))
	solve(n, arr)


t = int(input())
cases = []
for i in range(t):
	case = []
	case.append(int(input()))
	p = [item for item in input().split()]
	case.append(p)
	cases.append(case)
for case in cases:
	n = case[0]
	p = case[1]
	for i in range(1, n + 1):
		while p.count(str(i)) > 1:
			p.remove(str(i))
	print(' '.join(p))


for _ in range(int(input())):
	n = int(input())
	arr = []
	a = list(map(int, input().strip().split()))[:2 * n]
	for element in a:
		if element not in arr:
			arr.append(element)
	print(*arr)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	saw = set()
	for num in a:
		if num in saw:
			saw.remove(num)
		else:
			print(num, end=' ')
			saw.add(num)
	print()


t = int(input())
length = []
tests = []
for i in range(t):
	length += [int(n) for n in input().strip().split()]
	tests += [[int(n) for n in input().strip().split()]]
for test in tests:
	answer = [test[0]]
	i = 1
	while len(answer) < len(test) / 2:
		if test[i] not in answer:
			answer += [test[i]]
		i += 1
	print(*answer)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	prc = []
	for j in a:
		if j not in prc:
			prc.append(j)
	print(' '.join([str(x) for x in prc]))


t = int(input())
dic = dict()
for _ in range(t):
	dic.clear()
	m = int(input())
	nums = map(int, input().split())
	for n in nums:
		if n in dic:
			continue
		else:
			dic[n] = 1
			print(n, end=' ')
	print()


for _ in [0] * int(input()):
	(n, b, a) = (int(input()), [], list(map(int, input().split())))
	for i in a:
		if i not in b:
			b.append(i)
	print(*b)


n = int(input())
for i in range(n):
	m = int(input())
	x = list(map(int, input().split()))
	j = 0
	check = []
	while j < 2 * m:
		if x[j] in x[j + 1:]:
			print(x[j], end=' ')
		j += 1
	print()


t = int(input())
k = 0
for i in range(0, t):
	n = int(input())
	l = list(map(int, input().split()))
	p = [0]
	p[0] = l[0]
	for j in range(0, 2 * n - 1):
		if p.count(l[j]) == 0:
			p.append(l[j])
	for i in range(0, n):
		print(p[i], end=' ')
	print()


t = int(input(''))
for i in range(t):
	n = int(input(''))
	l = list(map(int, input().split()))
	d = {}
	m = []
	for item in l:
		d[item] = d.get(item, 0) + 1
		if d[item] == 1:
			m.append(item)
	print(*m)


def main():
	for _ in range(int(input())):
		n = int(input())
		arr = input().split()
		d = {}
		for p in range(len(arr)):
			if d.get(arr[p]) != None:
				d[arr[p]] += 1
			else:
				d[arr[p]] = 1
		for q in range(len(arr)):
			if d[arr[q]] % 2 == 0:
				print(arr[q], end=' ')
			d[arr[q]] -= 1
		print('')
main()


n = int(input())
for _ in range(n):
	c = int(input())
	df = list(input().split())
	d = []
	for x in range(c * 2):
		if df[x] not in d:
			d.append(df[x])
	print(' '.join(d))


t = int(input())
for i in range(t):
	n = int(input())
	seq = list(map(int, input().split()))
	hm = []
	for j in seq:
		if j not in hm:
			hm.append(j)
	print(*hm, sep=' ')


a = int(input())
main_list = []
for i in range(a):
	cnt = 0
	x = int(input())
	x_list = list(map(int, input().split()))
	for j in range(len(x_list)):
		for k in range(len(x_list)):
			if x_list[j] == x_list[k] and k != j and (x_list[k] != -1):
				x_list[k] = -1
				cnt += 1
			if cnt >= x:
				break
	main_list.append(x_list)
for i in range(len(main_list)):
	for j in range(len(main_list[i])):
		if main_list[i][j] != -1:
			print(main_list[i][j], end=' ')
	print()


for tc in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	dict = {}
	for i in lst:
		if len(dict) == n:
			break
		if i not in dict:
			dict[i] = 1
	for i in dict:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mp = {}
	for i in a:
		mp[i] = 0
	ans = []
	for i in a:
		mp[i] += 1
		if mp[i] == 1:
			ans.append(i)
	print(*ans, sep=' ')


from collections import OrderedDict
prakriti = int(input())
for i in range(prakriti):
	nexa = int(input())
	prateek = input().split()
	chandnarayan = list(OrderedDict.fromkeys(prateek))
	print(*chandnarayan, sep=' ')


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	z = []
	for i in range(2 * n):
		if a[i] not in z:
			z.append(a[i])
			ans.append(a[i])
	print(*ans)


from sys import stdin

def main():
	cases = int(stdin.readline())
	for i in range(cases):
		size = int(stdin.readline())
		lis = [int(j) for j in stdin.readline().strip().split()]
		resul = list(dict.fromkeys(lis))
		print(*resul)
main()


t = int(input())
for t1 in range(t):
	x = int(input())
	arr = list(map(int, input().split()))
	s = set()
	out = []
	for a in range(len(arr)):
		if not arr[a] in s:
			out.append(arr[a])
			s.add(arr[a])
	print(*out)


from collections import *
a = int(input())
for i in range(a):
	al = defaultdict(int)
	r = int(input())
	z = list(map(int, input().split()))
	ans = []
	for i in range(len(z)):
		if al[z[i]] == 0:
			al[z[i]] = 1
			ans.append(z[i])
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	u = []
	ans = []
	for i in l:
		if u.__contains__(i):
			continue
		else:
			u.append(i)
	for i in u:
		print(i, end=' ')
	print()


test_cases = int(input())
for i in range(test_cases):
	a_length = int(input()) * 2
	a = [int(i) for i in input().split()]
	p = []
	for j in range(a_length):
		if a[j] not in p:
			p.append(a[j])
	print(*p)


t = int(input())

def p(L):
	while len(L) > 2:
		print(L[0], end=' ')
		a = L.pop(0)
		L.remove(a)
	if len(L) == 2:
		print(L[0])
for _ in range(t):
	n = int(input())
	L = []
	ch = input().split(' ')
	for i in ch:
		L.append(int(i))
	p(L)


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right

def solve():
	n = int(input())
	a = list(map(int, stdin.readline().split()))
	ans = [0] * n
	curr = 0
	s = set()
	for i in a:
		if i not in s:
			s.add(i)
			ans[curr] = i
			curr += 1
	print(*ans)
t = 1
t = int(input())
for _ in range(t):
	solve()


import math
t = int(input())
for w in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l1 = []
	for i in l:
		if i not in l1:
			l1.append(i)
	print(*l1)


def ans(a, n):
	d = {}
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	lis = list(d.keys())
	s = ''
	for i in lis:
		s = s + str(i) + ' '
	return s
m = int(input())
for i in range(m):
	n = int(input())
	arr = input().split()
	a = []
	for i in arr:
		a.append(int(i))
	print(ans(a, n))


def find(s, list1):
	secondlist = []
	a = set()
	for i in list1:
		if i not in a:
			secondlist.append(str(i))
		a.add(i)
	print(' '.join(secondlist))
n = int(input())
for i in range(0, n):
	s = int(input())
	list1 = list(map(int, input().split()))
	find(s, list1)


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	c1 = []
	d = dict()
	for j in range(2 * n):
		if b[j] not in d.keys():
			c1.append(b[j])
		d[b[j]] = 1
	print(*c1)


for test in range(0, int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	ans = []
	for i in arr:
		if i not in ans:
			ans.append(i)
	print(*ans)


import io, os
from collections import deque
RL = lambda : list(map(int, input().split(' ')))
T = int(input())
for _ in range(T):
	n = int(input())
	l = RL()
	dic = [0] * (n + 1)
	ans = []
	for i in range(2 * n):
		if dic[l[i]] == 0:
			ans.append(l[i])
			dic[l[i]] = 1
	print(*ans)


class B:

	def __init__(self):
		self.n = int(input())
		self.a = [int(x) for x in input().split()]

	def solve_and_print(self):
		(n, a) = (self.n, self.a)
		seen = [False] * (n + 1)
		ans = [0] * n
		idx = 0
		for ai in a:
			if not seen[ai]:
				seen[ai] = True
				ans[idx] = ai
				idx += 1
		print(*ans)
for _ in range(int(input())):
	B().solve_and_print()


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [0 for i in range(n)]
	l = []
	for j in range(2 * n):
		if b[a[j] - 1] == 0:
			b[a[j] - 1] = 1
			l.append(str(a[j]))
	print(' '.join(l))


def restore_permutation(array):
	n = len(array) // 2
	found = [False] * n
	for num in array:
		if found[num - 1]:
			continue
		found[num - 1] = True
		print(f'{num} ', end='')
	print()
t = int(input())
for _ in range(t):
	n = int(input())
	array = [int(x) for x in input().split()]
	restore_permutation(array)


t = int(input())
for z in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	l2 = []
	for i in l:
		if i in d.keys():
			pass
		else:
			d[i] = 1
			l2.append(i)
	for y in l2:
		print(y, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	found = []
	for i in range(len(a)):
		if a[i] not in found:
			found.append(a[i])
	print(*found)


for t in range(int(input())):
	(n, v) = (int(input()), [])
	f = [False] * (n + 1)
	for x in map(int, input().split()):
		if not f[x]:
			v.append(x)
			f[x] = True
	print(' '.join(map(str, v)))


t = int(input())
for tc in range(t):
	n = int(input())
	line = input().split()
	arr = []
	for x in range(len(line)):
		arr.append(int(line[x]))
	p = 1
	q = n - 2
	i = 0
	ans = [-1] * n
	j = len(arr) - 1
	ans[0] = arr[i]
	ans[n - 1] = arr[j]
	i += 1
	j -= 1
	while i < j:
		if arr[i] not in ans:
			ans[p] = arr[i]
			p += 1
		if arr[j] not in ans:
			ans[q] = arr[j]
			q -= 1
		i += 1
		j -= 1
	for i in range(n):
		print(ans[i], end=' ')
	print('')


for _ in range(int(input())):
	N = int(input())
	permu = list(map(int, input().split()))
	ans = []
	for i in permu:
		if i not in ans:
			ans.append(i)
		else:
			pass
	print(' '.join(map(str, ans)))


def sol():
	n = int(input())
	strn = input().split()
	res = []
	for i in strn:
		while int(i) not in res and len(res) != n:
			res.append(int(i))
	return res
for i in range(int(input())):
	res = sol()
	for k in res:
		if k != res[-1]:
			print(k, end=' ')
		else:
			print(k)


for item in range(int(input())):
	n = int(input())
	mass = list(map(int, input().split()))
	rem = [0] * n
	ans = []
	for item in mass:
		if rem[item - 1] == 0:
			rem[item - 1] = 1
			ans.append(item)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().strip().split(' ')))
	lst = list(dict.fromkeys(lst))
	for j in range(n):
		print(lst[j], end=' ')
	print()


from collections import *
n = int(input())
for i in range(n):
	t = int(input())
	d = list(map(int, input().split()))
	count = Counter(d)
	s = [i for i in count.keys()]
	print(*s)


def main():
	for _ in range(int(input())):
		n = int(input())
		arr = [0] * n
		barr = [0] * n
		merged = list(map(int, input().split()))
		j = 0
		for i in merged:
			if j == n:
				break
			if arr[i - 1]:
				continue
			else:
				arr[i - 1] = 1
				barr[j] = str(i)
				j += 1
		print(' '.join(barr))
main()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	p = sorted(set(arr), key=arr.index)
	print(*p, sep=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	b = []
	for i in A:
		if str(i) not in b:
			b.append(str(i))
	print(' '.join(b))


cases = int(input())
for _ in range(cases):
	_ = input()
	result = [int(x) for x in input().split()]
	perm = []
	for p in result:
		if p not in perm:
			perm.append(p)
	for d in perm:
		print(d, end=' ')
	print()


q = int(input())
for i in range(q):
	n = int(input())
	f = []
	for i in range(n):
		f.append(1)
	l = list(map(int, input().split()))
	for i in range(2 * n):
		if f[l[i] - 1]:
			print(l[i], end=' ')
			f[l[i] - 1] = 0
	print(' ')


def func(n):
	a = input().split()
	ls = []
	for i in a:
		if not i in ls:
			ls.append(i)
	str1 = ls[0] + ' '
	for i in range(1, len(ls)):
		str1 += ls[i] + ' '
	print(str1)
t = int(input())
for i in range(0, t):
	n = int(input())
	func(n)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dl = []
	for i in range(len(a)):
		if a[i] not in dl:
			dl.append(a[i])
	for j in range(len(dl)):
		print(dl[j], end=' ')


results = []
tests = int(input())
for _x in range(tests):
	tempRes = []
	n = int(input())
	a = list((int(item) for item in input().split()))[:n * 2]
	checkList = [(0, 0)] * n
	for x in range(len(a)):
		checkList[a[x] - 1] = (x, a[x]) if checkList[a[x] - 1] == (0, 0) else checkList[a[x] - 1]
	checkList.sort(key=lambda tup: tup[0])
	tempRes = [item[1] for item in checkList]
	results.append(tempRes)
for item in results:
	print(*item)


a = int(input())
ans = []
for i in range(a):
	z = int(input())
	l1 = [0 for i in range(z + 1)]
	l = list(map(int, input().split()))
	tmp = []
	for i in l:
		if l1[i] == 0:
			tmp += [i]
			l1[i] += 1
	ans += [tmp]
for i in ans:
	for j in i:
		print(j, end=' ')
	print()


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
sys.setrecursionlimit(10 ** 6)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k)))) % NUMBER
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def get_num_2_5(n):
	twos = 0
	fives = 0
	while n > 0 and n % 2 == 0:
		n //= 2
		twos += 1
	while n > 0 and n % 5 == 0:
		n //= 5
		fives += 1
	return (twos, fives)

def shift(a, i, num):
	for _ in range(num):
		(a[i], a[i + 1], a[i + 2]) = (a[i + 2], a[i], a[i + 1])

def equal(x, y):
	return abs(x - y) <= 1e-09

def getAngle(a, b, c):
	ang = math.degrees(math.atan2(c[1] - b[1], c[0] - b[0]) - math.atan2(a[1] - b[1], a[0] - b[0]))
	return ang + 360 if ang < 0 else ang

def getLength(a, b):
	return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
from heapq import heapify, heappush, heappop

def bfs(adj):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

def dfs(u, top, adj, vis):
	vis[u] = 1
	for (v, d) in adj[u]:
		if vis[v] == 2 or d == 0:
			continue
		if vis[v] == 1:
			return 'No'
		if dfs(v, top, adj, vis) == 'No':
			return 'No'
	vis[u] = 2
	top.append(u)

def solution(a, n):
	s = defaultdict(int)
	for x in a:
		s[x]
	return ' '.join(map(str, s.keys()))

def main():
	T = 1
	T = ri()
	for i in range(T):
		n = ri()
		a = ria()
		x = solution(a, n)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	di = {}
	for i in range(len(a)):
		if a[i] not in di:
			di[a[i]] = 1
		else:
			di[a[i]] += 1
	l = []
	for i in di.keys():
		l.append(i)
	print(' '.join(map(str, l)))


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	k = [False for i in range(n + 1)]
	m = []
	for i in range(2 * n):
		if k[l[i]] == False:
			m.append(l[i])
			k[l[i]] = True
	print(*m, sep=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	included = [0] * n
	ans = []
	for elem in a:
		if included[elem - 1] == 0:
			ans.append(str(elem))
			included[elem - 1] = 1
	print(' '.join(ans))


inp_test = int(input())
for i in range(inp_test):
	l = int(input())
	list_inp = list(map(int, input().split(' ')))
	reversed(list_inp)
	list_out = []
	for i in list_inp:
		if len(list_out) == l:
			break
		elif i not in list_out:
			list_out.append(i)
		else:
			continue
	for i in list_out:
		print(i, end=' ')
	print('')


t = int(input())
for i in range(t):
	n = int(input())
	num = input().split(' ')
	for y in range(len(num)):
		num[y] = int(num[y])
	output = []
	for x in num:
		if x not in output:
			output.append(x)
			print(x)


t = int(input())
for i in range(t):
	n = int(input())
	di = {}
	for j in range(1, n + 1):
		di[j] = 0
	li = list(map(int, input().split()))
	result = []
	for k in li:
		if di[k] == 0:
			result.append(str(k))
			di[k] = 1
	print(' '.join(result))


def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		A = [int(i) for i in input().split()]
		B = set()
		ans = []
		for a in A:
			if a in B:
				continue
			ans.append(a)
			B.add(a)
		print(*ans)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [1] * (n + 1)
	p = []
	for x in a:
		if b[x]:
			p += (x,)
			b[x] = 0
	print(*p)


n = int(input())
cases = [(int(input()), input().split()) for _ in range(n)]
for case in cases:
	st = []
	for i in case[1]:
		if i not in st:
			st.append(i)
		if len(st) == case[0]:
			print(' '.join(st))
			break


for i in range(int(input())):
	length = int(input())
	jumbled_perm = input().split(' ')
	perm = []
	for _ in range(length):
		x = jumbled_perm[0]
		perm.append(jumbled_perm[0])
		jumbled_perm.remove(x)
		jumbled_perm.remove(x)
	print(' '.join([str(element) for element in perm]))


t = int(input())

def numbers(l):
	li = []
	for i in l:
		if i not in li:
			li.append(i)
			print(i, end=' ')
for j in range(0, t):
	n = int(input())
	l = list(map(int, input().split()))
	numbers(l)


t = int(input())
while t > 0:
	n = input()
	a = list(map(int, input().split()))
	res = []
	[res.append(x) for x in a if x not in res]
	for i in res:
		print(str(i), end=' ')
	print('')
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	s = set()
	ans = []
	for ele in arr:
		if ele not in s:
			ans.append(ele)
			s.add(ele)
	print(*ans)


cases = int(input())
for i in range(cases):
	n = int(input())
	l2 = input().split(' ')
	arr = []
	for a in l2:
		arr.append(a)
	ori = []
	for b in arr:
		if b not in ori:
			ori.append(b)
	print(' '.join(ori))


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	vis = [False] * (n + 1)
	b = []
	for i in a:
		if vis[i]:
			continue
		vis[i] = True
		b.append(i)
	print(' '.join(map(str, b)))


t = int(input())
while t > 0:
	n = int(input())
	list1 = list(map(int, input().split()))
	list2 = []
	for i in list1:
		if i not in list2:
			print(i, end=' ')
			list2.append(i)
	print()
	t -= 1


for _ in range(int(input())):
	N = int(input())
	X = list(map(int, input().split()))
	Status = [True] * N
	for i in X:
		if Status[i - 1]:
			print(i, end=' ')
			Status[i - 1] = False
	print()


from collections import Counter, defaultdict, deque
import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	arr = [int(x) for x in input().split()]
	s = set()
	ans = []
	for el in arr:
		if el in s:
			pass
		else:
			ans.append(el)
			s.add(el)
	print(*ans)
tt = int(input())
for test in range(tt):
	solve()


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	n = sInt()
	a = lInt()
	ans = []
	for i in a:
		if i not in ans:
			ans.append(i)
	print(*ans, sep=' ')


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	B = []
	for i in range(0, 2 * n):
		if A[i] not in B:
			print(A[i], end=' ')
			B.append(A[i])
	print('')


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	l = []
	for i in s:
		if i not in l:
			l.append(i)
	for i in l:
		print(i, end=' ')
	print()


import sys

def get_list_from_buffer(str_buffer):
	_ = next(str_buffer)
	set1 = set()
	lst = []
	for i in next(str_buffer).strip().split(' '):
		if i not in set1:
			set1.add(i)
			lst.append(i)
	return lst
nums = int(next(sys.stdin))
for i in range(nums):
	lst = get_list_from_buffer(sys.stdin)
	print(' '.join((i for i in lst)))


def check(n, l):
	h = []
	for i in l:
		if i not in h:
			h.append(i)
	print(*h)
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	check(n, l)


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	d = dd(int)
	a = []
	for i in l:
		if d[i] == 0:
			a.append(i)
		d[i] = 1
	print(*a)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def solve(t):
	n = int(input())
	data = map(int, input().split(' '))
	already = set()
	for num in data:
		if num not in already:
			print(num, end=' ')
			already.add(num)
	print()

def main():
	tc = int(input().strip())
	for t in range(1, tc + 1):
		solve(t)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	check = []
	ans = []
	for i in range(len(a)):
		if a[i] in check:
			pass
		else:
			check.append(a[i])
			ans.append(a[i])
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(' '.join(map(str, list(set(a)))))


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	count = {}
	for i in lst:
		if i not in count:
			count[i] = 1
			print(i, end=' ')
	print()


T = int(input())
for t in range(T):
	n = int(input())
	arr = [int(x) for x in input().split()]
	count = [0] * (n + 1)
	p = []
	for e in arr:
		count[e] += 1
		if count[e] == 1:
			p.append(e)
	print(*p)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	checklist = [0] * n
	ans = []
	for i in arr:
		if checklist[i - 1] == 0:
			ans.append(i)
			checklist[i - 1] = 1
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	lst = []
	for i in arr:
		if i not in d:
			d[i] = 1
	for i in d.keys():
		lst.append(i)
	for i in lst:
		print(i, end=' ')
	print()
	t -= 1


from collections import OrderedDict
ncases = int(input())
for _ in range(ncases):
	input()
	perm_merged = map(int, input().split())
	log = OrderedDict()
	for x in perm_merged:
		log[x] = None
	for x in log.keys():
		print(x, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	i = 0
	l1 = []
	while i < len(a) and len(l1) != n:
		if a[i] not in l1:
			l1.append(a[i])
		i += 1
	for i in l1:
		print(i, end=' ')


t = int(input())
(l, p) = (list('a') * t, list('b') * t)
lista = list()
for x in range(t):
	l[x] = int(input())
	p[x] = list(input().split())
	for y in range(l[x] * 2):
		if p[x][y] in lista:
			continue
		else:
			lista.append(p[x][y])
	print(*lista)
	lista = []


t = int(input())
from collections import Counter
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	c = Counter()
	for (i, a) in enumerate(arr):
		c[a] += i
	res = sorted(range(1, n + 1), key=lambda x: c[x])
	print(' '.join(map(str, res)))


tests = int(input())
for current_test in range(tests):
	size = int(input())
	lst = list(map(int, input().strip().split()))[:2 * size]
	save = list()
	out = list()
	for i in lst:
		try:
			save.index(i)
		except:
			out.append(i)
			save.append(i)
	for i in out:
		if out.index(i) != 0:
			print(' ', end='')
		print(i, end='')
	print()


tt = int(input())
lis = [-1] * 60
for loop in range(tt):
	n = int(input())
	p = list(map(int, input().split()))
	ans = []
	for i in p:
		if lis[i] == loop:
			continue
		else:
			ans.append(i)
			lis[i] = loop
	print(*ans)


T = int(input())
for i in range(T):
	N = int(input())
	x = 2 * N
	lst = list(map(int, input().split()))[:x]
	a = []
	for i in range(len(lst)):
		if lst[i] not in a:
			a.append(lst[i])
	print(*a)


def solve(n, d):
	big = float('inf')
	small = float('-inf')
	c = [0] * (n + 1)
	ans = ''
	for i in d:
		if c[i] == 0:
			c[i] = 1
			ans += str(i) + ' '
	return ans

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		d = input()
		d = [int(i) for i in d.split()]
		ans = solve(n, d)
		print(ans)
main()


test_cases = int(input())
final = []
for i in range(test_cases):
	n = int(input())
	stri = ''
	l = [int(x) for x in input().split()]
	final_l = []
	for j in range(len(l)):
		if l[j] not in final_l:
			final_l.append(l[j])
			stri = stri + str(l[j]) + ' '
	final.append(stri)
for i in range(len(final)):
	print(final[i])


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	print(*set(a))


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	k = list(map(int, input().split()))
	f = set(k)
	ans = []
	for i in k:
		if i in ans:
			continue
		t = k.index(i)
		q = k[::-1].index(i)
		q = len(k) - q
		for j in range(t, q + 1):
			if k[j] in k[j + 1:]:
				ans.append(k[j])
				break
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	r = []
	i = 0
	j = 1
	while len(r) != n:
		while j < len(a) and a[j] != a[i]:
			j += 1
		r.append(a[i])
		a[i] = -1
		a[j] = -1
		while i < len(a) and a[i] == -1:
			i += 1
		j += 1
		if i == j:
			j += 1
	for x in r:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	v = [0 for i in range(n + 1)]
	s = []
	for i in range(2 * n):
		if v[a[i]] == 0:
			v[a[i]] = 1
			s.append(a[i])
	print(*s)


n = int(input())
for i in range(n):
	q = int(input())
	a = list(map(int, input().split()))
	was = [0] * q
	ans = []
	for k in range(len(a)):
		if was[a[k] - 1] < 1:
			was[a[k] - 1] += 1
			ans.append(a[k])
		else:
			was[a[k] - 1] += 1
	print(*ans)


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	s = []
	for i in arr:
		if i not in s:
			print(i, end=' ')
			s.append(i)
	print()
	t -= 1


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	Dict = defaultdict(int)
	ans = []
	for i in arr:
		if Dict[i] == 0:
			ans.append(i)
			Dict[i] += 1
	print(*ans)


for _ in range(int(input())):
	input()
	P = set()
	for a in input().split():
		if a not in P:
			print(a, end=' ')
			P.add(a)
	print()


from collections import Counter
for t in range(int(input())):
	n = int(input())
	l = [int(_) for _ in input().split()]
	d = Counter(l)
	l = d.keys()
	for _ in l:
		print('{}'.format(_), end=' ')


t = 1
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	hashmap = {}
	for el in a:
		if el in hashmap:
			continue
		else:
			hashmap[el] = True
			print(el, end=' ')
	print('')


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	d = dd(int)
	for i in l:
		if d[i] == 0:
			print(i, end=' ')
			d[i] = 1
	print()
	t -= 1


t = int(input())
for i in range(t):
	k = int(input())
	l = list()
	a = input().split(' ')
	for j in range(2 * k):
		for h in range(j):
			if a[h] == a[j]:
				l.append(a[h])
				break
	for m in l:
		print('{} '.format(m), end='')
	print('\n')


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		d = {}
		ans = []
		for x in l:
			if d.get(x, -1) == -1:
				ans.append(x)
				d[x] = 1
		print(*ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


for _ in range(int(input())):
	t = int(input())
	n = list(map(int, input().split()))
	li = list()
	li.append(n[0])
	for x in n:
		if x not in li:
			li.append(x)
	print(*li)


t = int(input())
for i in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	s = set()
	a = []
	for e in array:
		if e not in s:
			a.append(str(e))
		s.add(e)
	print(' '.join(a))


r = 4
asg = 6
t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for i in range(n * 2):
		if a[i] not in p:
			p.append(a[i])
	for i in range(n):
		print(p[i], end=' ')
	print()


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = list(Counter(a))
	for i in l:
		print(i, end=' ')


for _ in range(int(input())):
	n = int(input())
	lst = map(int, input().split())
	lk = []
	for i in lst:
		if i not in lk:
			lk.append(i)
	for i in lk:
		print(i, end=' ')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	aa = []
	for j in a:
		if j not in aa:
			aa.append(j)
	print(*aa)


x = int(input())
for i in range(x):
	l = []
	y = int(input())
	r = [int(i) for i in input().split()]
	for i in r:
		if i not in l:
			l.append(i)
		if len(l) == y:
			break
	for i in l:
		print(i, end=' ')
	print()


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	s = 2 * n
	lst = list(map(int, input().split()))
	dict = [0] * (n + 1)
	for i in range(s):
		if dict[lst[i]] == 0:
			print(lst[i], ' ')
		dict[lst[i]] += 1
	print('\n')


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	ans = []
	for i in range(2 * n):
		if a[i] not in d:
			d[a[i]] = 1
			ans.append(a[i])
	print(*ans)


t = int(input())
for case in range(t):
	n = int(input())
	List = [int(j) for j in input().split(' ')]
	List_1 = []
	for i in range(2 * n):
		if List[i] not in List_1:
			List_1.append(List[i])
	for k in range(n - 1):
		print(List_1[k], end=' ')
	print(List_1[n - 1])


t = int(input())
perm = []
for i in range(t):
	n = int(input())
	nums = input().split()
	for j in range(len(nums)):
		nums[j] = int(nums[j])
	for j in range(len(nums)):
		if j == 0:
			perm.append(nums[j])
		elif nums[j] != nums[j - 1] and (nums[j] not in perm) == True:
			perm.append(nums[j])
	print(*perm)
	perm = []


x = int(input())
for i in range(x):
	a = int(input())
	l = list(map(int, input().split()))
	b = []
	b.append(l[0])
	j = 1
	while len(b) != a:
		if l[j] not in b:
			b.append(l[j])
		j += 1
	print(*b)


for i in range(int(input())):
	permutation_length = int(input())
	merged_permutation = input().split()
	permutation = dict.fromkeys(merged_permutation)
	print(' '.join(permutation.keys()))


t = int(input())
for i in range(t):
	n = int(input())
	s = [int(i) for i in input().split()]
	a = []
	for i in range(n):
		a.append(0)
	for i in s:
		a[i - 1] += 1
	for i in range(n):
		a[i - 1] /= 2
	for i in s:
		if a[i - 1] > 0:
			print(i, end=' ')
			a[i - 1] -= 1
	print()


for y in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	st1 = []
	st2 = []
	for i in range(2 * n):
		if len(st1) > 0 and st1[0] == lst[i]:
			st1.pop(0)
		else:
			st1.append(lst[i])
			st2.append(lst[i])
	for i in st2:
		print(i, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in a:
		if i not in ans and len(ans) < n:
			ans.append(i)
		elif len(ans) >= n:
			break
	for i in ans:
		print(i, end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	li = []
	for i in arr:
		if i not in li:
			li.append(i)
	print(*li)


def main():
	for t in range(int(input())):
		n = int(input())
		a = [int(x) for x in input().split()]
		empty = []
		for i in a:
			if i not in empty:
				empty.append(i)
		print(*empty)
main()


from collections import OrderedDict
for i in range(int(input())):
	n = int(input())
	a = list(map(str, input().split()))
	d = OrderedDict()
	for i in a:
		d[i] = 1
	a = list(d.keys())
	print(*a)


t = int(input())
l = []
for i in range(t):
	n = int(input())
	s = input().split()
	l.append(s)
for j in l:
	l1 = []
	for k in j:
		if k not in l1:
			l1.append(k)
			print(k, end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	li = [0] * n
	final = []
	for i in range(n * 2):
		if li[arr[i] - 1] == 0:
			final.append(arr[i])
			li[arr[i] - 1] = 1
	print(*final)


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	vis = [0] * (n + 1)
	ans = []
	for i in map(int, input().split()):
		if not vis[i]:
			ans.append(i)
			vis[i] = 1
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = input().split()
	temp = []
	hasil = []
	for i in arr:
		if i not in temp:
			hasil.append(i)
			if len(hasil) == n:
				break
		temp.append(i)
	print(' '.join(hasil))


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	ans = []
	dic = {}
	for i in A:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
			ans.append(i)
	print(*ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for ele in a:
		if ele not in p:
			p.append(ele)
	print(*p)


try:
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		m = []
		for i in l:
			if i not in m:
				m.append(i)
		print(*m)
except:
	pass


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	d = {}
	res = []
	for i in list(map(int, stdin.readline().split())):
		if i not in d:
			d[i] = 1
			res.append(i)
	print(*res)


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().rstrip().split(' ')))
	output = []
	taken = set()
	for ele in p:
		if ele not in taken:
			output.append(ele)
			taken.add(ele)
	print(*output)


test_case = int(input())
for _ in range(test_case):
	n = input()
	arr = list(map(int, input().split()))
	brr = [0 for i in range(len(arr))]
	for i in range(len(arr)):
		if not brr[arr[i] - 1]:
			print(arr[i], end=' ')
			brr[arr[i] - 1] = 1
	print()


import sys

def solve(s):
	ans = []
	seen = set()
	for x in s.split():
		if x not in seen:
			ans.append(x)
			seen.add(x)
	return ' '.join(ans)
next(sys.stdin)
while True:
	if not next(sys.stdin, ''):
		break
	ln = next(sys.stdin)
	s = ln.strip()
	print(solve(s))


for i in range(int(input())):
	n = int(input())
	line = input().split()
	arr = [True for x in range(n)]
	stroke = ''
	for el in line:
		if arr[int(el) - 1]:
			arr[int(el) - 1] = False
			stroke += el + ' '
	print(stroke[:len(stroke) - 1])


for t in range(int(input())):
	n = input()
	(l, s) = ([int(x) for x in input().split(' ')], [])
	for x in l:
		if x in s:
			continue
		else:
			s.append(x)
	for x in s:
		print(x, end=' ')
	print()


for k in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = []
	for i in range(2 * n):
		if arr[i] not in temp:
			temp.append(arr[i])
	for i in range(n):
		print(temp[i], end=' ')


def get_seq(n, a):
	D = {}
	L = []
	for i in range(1, n + 1):
		D[i] = 0
	for i in a:
		D[i] += 1
		if D[i] == 1:
			L.append(i)
	s = ''
	for i in L:
		s = s + str(i) + ' '
	return s
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(get_seq(n, a))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(2 * n):
		if str(a[i]) not in b:
			b.append(str(a[i]))
		if len(b) == n:
			break
	print(' '.join(b))


t = int(input())
rpta = []
for i in range(t):
	n = int(input())
	main = list(map(int, input().split()))
	temp = []
	for j in main:
		if j not in temp:
			temp.append(j)
	rpta.append(temp)
for maiden in rpta:
	print(*maiden)


for _ in range(int(input())):
	n = int(input())
	li = [int(i) for i in input().split()]
	a = []
	for i in li:
		if i in a:
			continue
		else:
			a.append(i)
	print(*a)


t = int(input())
for i in range(t):
	sxp = int(input())
	sp = list(map(int, input().split()))
	sp2 = []
	for j in sp:
		if sp.count(j) / 2 > sp2.count(j):
			print(j, end=' ')
			sp2.append(j)
	print()


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))
(t,) = mp()
for _ in range(t):
	(n,) = mp()
	a = mp()
	s = set()
	l = []
	for i in a:
		ln = len(s)
		s.add(i)
		if len(s) > ln:
			l += [i]
	for j in range(n):
		cout(str(l[j]) + ' ')
	cout('\n')


t = int(input())
for i in range(t):
	n = int(input())
	p2 = input().split()
	p = []
	for num in p2:
		if num not in p:
			p.append(num)
	print(' '.join(p))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for j in range(2 * n):
		if a[j] in p:
			continue
		else:
			p.append(a[j])
	print(' '.join(map(str, p)))


def main():
	t = int(input())
	lst = list(map(int, input().split()))
	st = set()
	ans = []
	for i in range(len(lst)):
		if lst[i] in st:
			continue
		ans.append(lst[i])
		st.add(lst[i])
	for k in ans:
		print(k, end=' ')
	print()
for _ in range(int(input())):
	main()


try:
	t = int(input())
	for v in range(t):
		n = int(input())
		d = dict()
		output = list()
		a = list(map(int, input().split()))
		for i in range(len(a)):
			if d.get(a[i], 0) == 0:
				d[a[i]] = 1
				output.append(a[i])
		for j in range(len(output)):
			print(output[j], end=' ')
		print()
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	temp = [1 for i in range(n)]
	a = list(map(int, input().split()))
	k = [0 for i in range(n)]
	x = 0
	for i in a:
		if temp[i - 1] == 1:
			temp[i - 1] = 0
			k[x] = i
			x += 1
	print(' '.join(map(str, k)))


testcases = int(input())
test_cases = []
for _ in range(testcases):
	x = input()
	seen = set()
	test_cases.append([x for x in input().split() if not (x in seen or seen.add(x))])
for i in test_cases:
	for item in i:
		print(item, end=' ')
	print()


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from fractions import Fraction
mod = int(1000000000.0) + 7
for t in range(int(data())):
	n = int(data())
	a = mdata()
	d = dd(int)
	ans = []
	for i in range(2 * n):
		d[a[i]] += 1
		if d[a[i]] == 2:
			ans.append(a[i])
			d[a[i]] = 0
	outl(ans)


n = int(input())
for j in range(n):
	a = int(input())
	lis = list(map(int, input().split()))
	arr = []
	for j in lis:
		if j not in arr:
			arr.append(j)
	print(*arr)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	set1 = list(set(lst))
	lst1 = []
	l = len(lst)
	for j in range(l):
		if lst[j] in set1:
			lst1.append(lst[j])
			set1.remove(lst[j])
	print(*lst1)


import sys
sys.setrecursionlimit(100000)
from collections import defaultdict
from collections import deque
import heapq
I = lambda : list(map(int, input().split(' ')))
for _ in range(int(input())):
	n = int(input())
	lst = I()
	dct = defaultdict(int)
	for i in range(n):
		dct[i + 1]
	for (j, ele) in enumerate(lst):
		if dct[ele] == 0:
			dct[ele] = j + 1
	print(' '.join(map(str, [e[1] for e in sorted([(dct[ele], ele) for ele in range(1, n + 1)])])))


from collections import OrderedDict
t = int(input())
for i in range(t):
	n = int(input())
	a = input().split()
	b = list(OrderedDict.fromkeys(a))
	print(*b, sep=' ')


t = int(input())
for i in range(t):
	n = int(input())
	z = [int(x) for x in input().split()]
	p = []
	for j in range(2 * n):
		if z[j] not in p:
			p.append(z[j])
			print(z[j], end=' ')
	print()


t = int(input())
for i in range(t):
	_ = input()
	x = input().split()
	ans = []
	while len(x) > 0:
		ans.append(x[0])
		del x[0]
	ans = list(dict.fromkeys(ans))
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = list()
	d = dict()
	for i in range(len(a)):
		if a[i] not in d.keys():
			ans.append(a[i])
			d[a[i]] = 1
		else:
			continue
	print(*ans, sep=' ')


for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	c = []
	for i in a:
		if i not in c:
			c.append(i)
	print(*c)


count = int(input())
for i in range(count):
	n = int(input())
	test = [int(j) for j in input().split()]
	answer = []
	for j in test:
		if j not in answer:
			answer.append(j)
	for j in answer:
		print(j, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	vt = []
	for i in range(2 * n):
		if p[i] not in vt:
			vt.append(p[i])
	print(*vt)


for _ in range(int(input())):
	input()
	x = [int(x) for x in input().split()]
	z = []
	for i in x:
		if i not in z:
			z.append(i)
	for i in z:
		print(i, end=' ')


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	mp = {}
	for x in a:
		if x in mp:
			mp[x] += 1
		else:
			mp[x] = 1
	for i in mp:
		print(i, end=' ')
	print()
	t -= 1


t = int(input())
while t:
	t -= 1
	n = int(input())
	x = list(map(int, input().split()))
	i = 1
	ans = []
	ans.append(x[0])
	j = 1
	while i < n:
		if x[j] not in ans:
			ans.append(x[j])
			i += 1
		j += 1
	for i in ans:
		print(i, end=' ')
	print()


import sys
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	q = []
	seq = []
	for x in arr:
		if not q or q[0] != x:
			q.append(x)
		else:
			q.pop(0)
			seq.append(x)
	print(' '.join((str(s) for s in seq)))


for _ in range(int(input())):
	n = int(input())
	freq = [0 for i in range(n + 7)]
	ar = list(map(int, input().split()))
	for i in ar:
		if freq[i] == 1:
			print(i, end=' ')
		freq[i] += 1
	print('')


t = int(input())
for i in range(t):
	ans = ''
	length = int(input())
	hash = [1] * length
	p = [int(s) for s in input().split(' ')]
	for el in p:
		if hash[el - 1] == 1:
			ans += str(el) + ' '
			hash[el - 1] = 0
	print(ans[:-1])


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		s = set()
		ans = []
		for i in arr:
			if i not in s:
				s.add(i)
				ans.append(i)
		print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
import os
import random
import re
import sys
from collections import Counter
import heapq
t = int(input())
for _ in range(t):
	l = []
	n = int(input())
	for i in range(n + 1):
		l.append(0)
	p = list(map(int, input().split()))
	for i in range(len(p)):
		if l[p[i]] == 0:
			print(p[i], end=' ')
			l[p[i]] = p[i]
	print()


t = int(input())
for i in range(t):
	mass = [0] * 51
	n = input()
	for j in input().split():
		if not mass[int(j)]:
			mass[int(j)] = 1
			print(j, end=' ')
	print('\n')


v = []
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	for i in l:
		if i not in v:
			v.append(i)
	for i in v:
		print(i, end=' ')
	v.clear()
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	d = {}
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	a = int(input())
	r = {}
	x = list(map(int, input().split()))
	for i in x:
		if i in r:
			pass
		else:
			r[i] = 1
	for i in r.keys():
		print(i, end=' ')
	print()


for s in [*open(0)][2::2]:
	t = {0}
	for x in map(int, s.split()):
		print(('', x)[x in t])
		t |= {x}


def find(l, n):
	ans = []
	seen = set()
	i = 0
	while len(ans) != n:
		if l[i] not in seen:
			seen.add(l[i])
			ans.append(l[i])
		i += 1
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print(*find(l, n), sep=' ')


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	r = []
	for i in l:
		if i not in r:
			r.append(i)
	print(*r)


T = int(input())
for t in range(T):
	n = int(input())
	A = [int(i) for i in input().split()]
	ans = []
	visited = [False for i in range(n + 1)]
	for i in A:
		if not visited[i]:
			ans.append(i)
			visited[i] = True
	print(*ans)


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	used = set()
	ans = []
	for a in A:
		if a not in used:
			ans.append(a)
			used.add(a)
	print(*ans, sep=' ')


for k in range(int(input())):
	n = int(input())
	ll = []
	for i in [int(i) for i in input().split()]:
		if i not in ll:
			ll.append(i)
			print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	seen = set()
	ans = []
	for i in a:
		if i not in seen:
			ans.append(i)
			seen.add(i)
	print(' '.join((str(x) for x in ans)))


def x(arr):
	ans = []
	for i in arr:
		if i not in ans:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(input().split())
	x(arr)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	for e in l:
		if e not in l1:
			l1.append(e)
	print(*l1)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	result = []
	for i in range(len(a)):
		if a[i] not in result:
			result.append(a[i])
	for k in result:
		print(k, end=' ')
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	lst = input().split()
	lst1 = []
	for i in lst:
		if i not in lst1:
			lst1.append(i)
	print(' '.join(lst1))


t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	s = set()
	List = list(map(int, input().split()))
	for val in List:
		if val not in s:
			ans.append(val)
			if len(ans) == n:
				break
			s.add(val)
	print(*ans)


from sys import stdin
input = stdin.readline
T = int(input())
for _ in range(T):
	l = int(input())
	msg = list(map(int, input().split()))
	ans = []
	for m in msg:
		if not m in ans:
			ans.append(m)
	print(*ans)


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = [0] * n
	l1 = []
	for i in l:
		if not f[i - 1]:
			f[i - 1] = 1
			l1.append(str(i))
	print(' '.join(l1))


def restore(l, a):
	b = []
	for i in a:
		if i not in b:
			b.append(i)
		if len(a) == l:
			break
	return b
ans = []
amount = int(input())
for i in range(amount):
	n = int(input())
	seq = list(map(int, input().split()))
	ans.append(restore(n, seq))
for i in ans:
	i = [str(x) for x in i]
	print(' '.join(i))


for i in range(int(input())):
	k = int(input())
	lis = list(map(int, input().split()))
	n = []
	for t in lis:
		if t not in n:
			n.append(t)
	for i in range(len(n)):
		if i != len(n) - 1:
			print(n[i], end=' ')
		else:
			print(n[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	li = []
	for i in range(0, len(a)):
		if a[i] not in li:
			li.append(a[i])
	print(*li)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dic = {}
	for i in range(len(a)):
		if a[i] not in dic:
			dic[a[i]] = i
	print(*dic)


n = int(input())
a = []
for i in range(n):
	k = int(input())
	b = [int(i) for i in input().split(' ')]
	for j in range(len(b)):
		a.append(b[j])
		for k in range(j + 1, len(b)):
			if b[k] == b[j]:
				b[k] = ''
				break
	for l in a:
		if l != '':
			print(l, end=' ')
	print('')
	a.clear()


t = int(input())
l = []
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	a = []
	for j in range(n):
		a.append(s[0])
		b = s[0]
		s.remove(b)
		s.remove(b)
	l.append(a)
for i in l:
	for j in i:
		print(j, end=' ')
	print('')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	for j in l:
		if j in l1:
			pass
		else:
			l1.append(j)
	print(' '.join(list(map(str, l1))))


t = int(input())
for case in range(t):
	n = int(input())
	p = []
	m = input().split(' ')
	i = 0
	while len(p) < n:
		if m[i] not in p:
			p.append(m[i])
		i += 1
	print(' '.join(p))


testcase = int(input())
for i in range(testcase):
	n = int(input())
	dic = {}
	li = list(map(int, input().split()))
	for i in li:
		dic[i] = 0
	li1 = []
	for i in li:
		if dic[i] == 0:
			dic[i] = 1
			li1.append(i)
	print(*li1)


for _ in range(int(input())):
	n = int(input())
	a = list((int(x) for x in input().split()))
	b = []
	lena = len(a)
	for i in range(lena):
		if a[i] in b:
			continue
		else:
			b.append(a[i])
	for i in range(len(b)):
		print(b[i], end=' ')
	print(' ')


from collections import defaultdict
t = int(input())
for i in range(t):
	d = defaultdict(lambda : 0)
	n = int(input())
	a = list(map(int, input().split()))
	for j in a:
		d[j] = 1
	print(*d.keys(), sep=' ')


t = int(input())
for test in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	seen = set()
	ans = []
	for val in arr:
		if val not in seen:
			ans.append(val)
			seen.add(val)
	print(*list(ans))


def A_normal(A):
	S = [A[0]]
	for i in range(1, len(A)):
		if A[i] not in S:
			S.append(A[i])
	print(*S)
	return
n = int(input())
for i in range(n):
	m = int(input())
	A = list(map(int, input().split()))
	A_normal(A)


t = int(input())
for _ in range(t):
	l = int(input())
	m = list(map(int, input().split()))
	p = []
	for e in m:
		if e not in p:
			p.append(e)
			print(e, end=' ')


t = int(input())
while t > 0:
	n = int(input())
	L = list(map(int, input().split()))
	d = {}
	for i in L:
		if i not in d:
			d[i] = 1
			print(i, end=' ')
	print()
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	al = list(map(int, input().split()))
	dic = {}
	ans = []
	for i in range(len(al)):
		if al[i] in dic:
			ans.append(al[i])
		else:
			dic[al[i]] = 1
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	vis = []
	for x in li:
		if x not in vis:
			vis.append(x)
	for y in vis:
		print(y, end=' ')
	print()


import sys, bisect
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	G = []
	B = [-1 for i in range(n)]
	for i in range(2 * n):
		if B[A[i] - 1] == -1:
			G.append(A[i])
			B[A[i] - 1] = 1
	print(*G)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	x = []
	for j in range(len(a)):
		if a[j] in d:
			d[a[j]] += 1
		else:
			d[a[j]] = 1
	for (key, value) in d.items():
		x.append(key)
	print(*x)


tcs = int(input())
for tc in range(tcs):
	n = int(input())
	arr = list(map(int, input().split()))
	v = set()
	res = []
	for a in arr:
		if a not in v:
			res.append(a)
			v.add(a)
	print(*res)


t = int(input())
while t > 0:
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = [0] * 1
	arr2[0] = arr1[0]
	for i in range(len(arr1)):
		if arr2.count(arr1[i]) > 0:
			continue
		else:
			arr2.append(arr1[i])
	print(*arr2)
	t -= 1


import sys
info = sys.stdin.readlines()
amount = int(info[0])
out = []
info = [list(map(int, info[i].split())) for i in range(2, amount * 2 + 2, 2)]
for i in range(amount):
	current = [str(info[i][x]) for x in range(len(info[i]))]
	current = list(set(current))
	out.append(current)
out = [' '.join(out[i]) for i in range(len(out))]
print('\n'.join(out))


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	ordered = []
	for ele in lst:
		if ele not in ordered:
			ordered.append(ele)
	print(' '.join(map(str, ordered)))


for _ in range(int(input())):
	n = int(input())
	seq = list(map(int, input().split()))
	isSelected = set()
	p = []
	for num in seq:
		if num in isSelected:
			continue
		else:
			p.append(str(num))
			isSelected.add(num)
	assert len(p) == n
	print(' '.join(p))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = []
	for i in range(len(l)):
		if l[i] in m:
			continue
		else:
			m.append(l[i])
	print(*m, sep=' ')


t = int(input())
for i in range(t):
	n = int(input())
	list1 = [int(x) for x in input().split(' ')]
	final_list = []
	j = 0
	while len(list1) != 0:
		final_list.append(list1[0])
		temp = list1[0]
		list1.remove(temp)
		list1.remove(temp)
	for k in range(len(final_list)):
		print(final_list[k], end=' ')


import sys
input = sys.stdin.readline
n = int(input())
for _ in range(n):
	m = int(input())
	vals = list(map(int, input().split()))
	d = set()
	ans = ''
	for v in vals:
		if v not in d:
			ans += str(v) + ' '
			d.add(v)
	print(ans[:-1])


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = l[0]
	act = [*range(1, n + 1)]
	ans = []
	for i in l:
		if i in act and len(act) != 0:
			ans.append(i)
			act.remove(i)
		if len(act) == 0:
			break
	for i in ans:
		print(i, end=' ')


t = int(input())

def freq(ar):
	tt = 0
	for x in ar:
		if x == 0:
			tt += 1
	return tt
for _ in range(t):
	l = int(input())
	k = list(map(int, input().split()))
	arr = [0 for _ in range(l)]
	p = 1
	h = 1
	arr[0] = k[0]
	arr[-1] = k[-1]
	while freq(arr) > 0:
		if k[p] not in arr:
			arr[h] = k[p]
			h += 1
		p += 1
	print(' '.join(list(map(str, arr))))


def foo():
	n = int(input())
	l = [int(x) for x in input().split()]
	k = [0] * n
	g = []
	for i in l:
		if k[i - 1] == 0:
			k[i - 1] += 1
			g.append(i)
	print(*g)
for _ in range(int(input())):
	foo()


t = int(input())
for i in range(t):
	n = int(input())
	a = map(int, input().split())
	ans = []
	for num in a:
		if num not in ans:
			ans.append(num)
	print(' '.join(map(str, ans)))


T = int(input())
for t in range(1, T + 1):
	n = int(input())
	lst = input().split()
	for i in range(2 * n):
		lst[i] = int(lst[i])
	tmp = []
	for i in range(2 * n):
		if not lst[i] in tmp:
			tmp.append(lst[i])
	for i in range(n):
		print(tmp[i], ' ', end='')
	print()


t = int(input())
for q in range(t):
	n = int(input())
	a = input()
	d = {}
	k = a.split()
	o = []
	for i in range(len(k)):
		k[i] = int(k[i])
	for word in k:
		if word in d:
			d[word] = d[word] + 1
			if d[word] % 2 != 0:
				o.append(word)
		else:
			d[word] = 1
			o.append(word)
	for i in o:
		print(i, end=' ')


t = int(input())
for _ in range(t):
	a = int(input())
	x = list(map(int, input().split()))
	y = set()
	z = []
	for i in range(len(x)):
		if x[i] not in y:
			z.append(x[i])
			y.add(x[i])
	print(*z)


t = int(input())
for i in range(t):
	n = int(input())
	lst = map(int, input().split())
	out = []
	for ele in lst:
		if ele not in out:
			out.append(ele)
	for ele in out:
		print(ele, end=' ')
	print('')


t = int(input())
for g in range(t):
	n = int(input())
	peres = list(map(int, input().split()))
	wait = []
	for j in range(n):
		wait.append(j + 1)
	ans = []
	for i in range(len(peres)):
		if peres[i] == wait[peres[i] - 1]:
			ans.append(peres[i])
			wait[peres[i] - 1] = -100
	print(*ans)


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	length = len(arr)
	appearance = set()
	for num in arr:
		if num not in appearance:
			print(num, end=' ')
			appearance.add(num)
	print()


t = int(input())
for testcase in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	for x in l:
		if ans == []:
			ans.append(x)
		elif x not in ans:
			ans.append(x)
	print(*ans)


tests = int(input())
for t in range(tests):
	n = int(input())
	ls = list(map(int, input().split()))
	num_dict = {}
	res = []
	for item in ls:
		if item not in num_dict:
			num_dict[item] = 1
		elif num_dict[item] == 1:
			num_dict[item] = 0
			res.append(item)
		else:
			num_dict[item] = 1
	print(' '.join(list(map(str, res))))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	s = [e for (i, e) in enumerate(arr) if arr.index(e) == i]
	print(*s)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	dic = defaultdict(bool)
	ans = []
	for i in arr:
		if not dic[i]:
			dic[i] = True
			ans.append(i)
	print(*ans)


def ans(n, array):
	s = set()
	output = []
	for i in array:
		if i not in s:
			output.append(i)
			s.add(i)
	print(*output)
	pass
t = int(input())
while t > 0:
	n = int(input())
	array = list(map(int, input().split()))
	ans(n, array)
	t -= 1
	pass


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	e = []
	for i in range(len(a)):
		if a[i] not in e:
			e.append(a[i])
	for i in range(len(e)):
		print(e[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	f = [0] * n
	s = []
	for i in range(2 * n):
		if f[a[i] - 1] == 0:
			s.append(a[i])
			f[a[i] - 1] += 1
	for i in range(n):
		print(s[i], end=' ')
	print('')


test_case = int(input())
for i in range(test_case):
	length = int(input())
	values = list(input().split(' '))
	values = set(values)
	print(' '.join(values))


for i in range(int(input())):
	arr_len = int(input())
	in_arr = [int(x) for x in input().split()]
	ans_arr = []
	for item in in_arr:
		if item in ans_arr:
			continue
		else:
			ans_arr.append(item)
		if len(ans_arr) == arr_len:
			break
	print(*ans_arr, sep=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = []
	for item in arr:
		if item not in temp:
			temp.append(item)
	for item in temp:
		print(item, end=' ')
	print()


n = int(input())
for i in range(n):
	l = int(input())
	ar = []
	a = list(map(int, input().split()))
	for i in a:
		if i not in ar:
			ar.append(i)
			print(i, end=' ')
	print()


for ty in range(int(input())):
	n = int(input())
	a = []
	a1 = input().split()
	for ij in a1:
		a += [int(ij)]
	l = []
	for i in a:
		if i not in l:
			l += [i]
	s = ''
	for j in l:
		s += str(j) + ' '
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	ans = []
	for i in range(2 * n):
		try:
			x = d[l[i]]
		except:
			ans.append(l[i])
			d[l[i]] = 0
	print(*ans)


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	dict = []
	for i in l:
		if i not in dict:
			print(i, end=' ')
			dict.append(i)
	print()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	temp = [0] * 52
	fin = list()
	for i in l:
		if temp[i] == 0:
			temp[i] = 1
			fin.append(i)
	print(*fin, sep=' ')


t = int(input())
assert 1 <= t <= 400
for i in range(t):
	n = int(input())
	assert 1 <= n <= 50
	l = list(map(int, input().split()))[:2 * n]
	for i in l:
		assert 1 <= i <= n
	k = []
	for i in l:
		if i not in k:
			k.append(i)
			print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in a:
		p = 0
		for j in ans:
			if j == i:
				p = 1
				break
		if p == 0:
			ans.append(i)
	print(*ans)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	ans = []
	for _ in range(n):
		k = I()
		d = {}
		l = LI()
		a = []
		for x in l:
			if x not in d:
				a.append(x)
				d[x] = x
		ans.append(a)
	for x in ans:
		print(' '.join((str(a) for a in x)))
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	print(*b)


n = int(input())
ans = []
for i in range(n):
	k = int(input())
	lst = list(map(int, input().split(' ')))
	dicts = {}
	ap = []
	for i in lst:
		dicts[str(i)] = i
	for i in dicts:
		ap.append(str(i))
	ans.append(ap)
for i in ans:
	print(' '.join(i))


for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	L1 = []
	for i in L:
		if i not in L1:
			L1.append(i)
	print(*L1)


def main():
	for t in range(int(input())):
		n = int(input())
		a = [int(i) for i in input().split()]
		res = []
		d = set()
		for i in a:
			if i not in d:
				d.add(i)
				res.append(i)
		for i in res:
			print(i, end=' ')
		print('')
main()


import math
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	d = {}
	for i in range(len(l)):
		if d.get(l[i], -1) == -1:
			d[l[i]] = 1
			ans.append(l[i])
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	z = []
	for i in a:
		if i not in z:
			z.append(i)
	print(*z)


for i in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	lst = list()
	for i in range(2 * n):
		if x[i] not in lst:
			lst.append(x[i])
		else:
			continue
	print(*lst, sep=' ')


n = int(input())
for i in range(n):
	w = int(input())
	l = [int(x) for x in input().split()]
	l = list(dict.fromkeys(l))
	print(*l, sep=' ')


test = int(input())
for i in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	arr_set = set()
	for i in range(2 * n):
		if arr[i] not in arr_set:
			print(arr[i], end=' ')
		arr_set.add(arr[i])
	print()


n = int(input())
for i in range(n):
	s = int(input())
	lis = list(map(int, input().split()))
	b = list(dict.fromkeys(lis))
	for j in b:
		if j in lis:
			print(j, end=' ')
	print()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	x = [int(x) for x in input().split()]
	arr1 = []
	arr2 = []
	for item in x:
		if item in arr1:
			arr2.append(item)
		else:
			arr1.append(item)
	print(*arr1)


t = int(input())
while t != 0:
	k = int(input())
	k = 2 * k
	arr = [int(x) for x in input().split()]
	ls = []
	for j in arr:
		if j not in ls:
			ls.append(j)
	for i in ls:
		print(i, end=' ')
	t -= 1


t = int(input())
c = []
for i in range(t):
	n = int(input())
	a = [int(u) for u in input().split()]
	s = ''
	while a:
		q = a.pop(0)
		a.pop(a.index(q))
		s += str(q)
		s += ' '
	c.append(s)
for k in c:
	print(k)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ar = []
	for i in range(len(a)):
		for j in range(i + 1, len(a)):
			if a[i] == a[j]:
				ar.append(a[j])
	print(*ar, sep=' ')


def solve(n, l):
	done = {}
	for i in l:
		if i not in done:
			print(i, end=' ')
			done[i] = 1
			if len(done.keys()) == n:
				print()
				return
	print()
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	solve(n, l)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = []
	i = 0
	while len(a) > n:
		if a[i] not in b:
			b.append(a[i])
			del a[i]
		else:
			i += 1
	print(' '.join([str(i) for i in a]))


n = int(input())
for _ in range(n):
	input()
	p = []
	vals = list(map(int, input().split()))
	for char in vals:
		if not char in p:
			p.append(char)
	print(' '.join(list(map(str, p))))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def solve():
	n = int(inp())
	ar = lis()
	s = set()
	ans = []
	for i in ar:
		if i in s:
			pass
		else:
			ans.append(i)
			s.add(i)
	printlist(ans)
	print()
testcase(int(inp()))


t = int(input())
for _ in range(t):
	temp = int(input())
	l1 = list(map(int, input().split()))
	s1 = []
	for val in l1:
		if val not in s1:
			s1.append(val)
	print(*s1)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	p = [l[0]]
	for i in range(1, n + n):
		if l[i] not in p:
			p.append(l[i])
	print(*p)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	d = set()
	b = []
	for i in range(2 * n):
		if a[i] not in d:
			b.append(str(a[i]))
			d.add(a[i])
	print(' '.join(b))
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	d = {}
	s = ''
	a = [int(v) for v in input().split()]
	for j in range(2 * n):
		if a[j] not in d:
			s = s + str(a[j]) + ' '
			d[a[j]] = 1
	print(s.strip())


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split(' ')))
	un = []
	for i in range(2 * n):
		if a[i] not in un:
			un.append(a[i])
	for i in range(n):
		print(un[i], end=' ')
	print()


t = int(input())
nLst = []
pLst = []
ansLst = []
for tt in range(t):
	nLst.append(int(input()))
	p = []
	p = input().split()
	for pp in range(len(p)):
		p[pp] = int(p[pp])
	pLst.append(p)
for i in range(t):
	ans = []
	for j in range(len(pLst[i])):
		if pLst[i][j] not in ans:
			ans.append(pLst[i][j])
	ansLst.append(ans)
for i in range(t):
	for j in range(len(ansLst[i])):
		print(ansLst[i][j], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(maxsplit=2 * n - 1)))
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	b = str(b).replace(',', '')
	print(b[1:-1])


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split()
	f = 0
	k = ''
	for j in s:
		if s.index(j) == f:
			k += j + ' '
		f += 1
	print(k)


t = int(input())
i = 1
while i <= t:
	n = int(input())
	n1 = 2 * n
	lst = list(map(int, input().strip().split()))[:n1]
	lst1 = []
	for j in range(0, 2 * n):
		if lst1.count(lst[j]) == 0:
			lst1 += [lst[j]]
	print(*lst1)
	i += 1


testcases = int(input())
for i in range(testcases):
	n = int(input())
	l = list(map(int, input().split()))
	result = [l[0]]
	for i in range(1, len(l)):
		if l[i] in result:
			continue
		else:
			result.append(l[i])
	for i in result:
		print(i, end=' ')


for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	s = set()
	ans = []
	for val in a:
		if val not in s:
			ans.append(val)
			s.add(val)
	print(*ans)


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')
from collections import deque as que, defaultdict as vector
from heapq import *
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
Testcase = inin()
for i in range(Testcase):
	n = inin()
	arr = inar()
	vis = [False for i in range(n + 1)]
	ans = []
	for i in arr:
		if not vis[i]:
			ans.append(i)
			vis[i] = True
	print(*ans)


def restore(inp):
	visited = set()
	output_str = ''
	for val in inp.split(' '):
		if val in visited:
			continue
		else:
			output_str += val + ' '
			visited.add(val)
			if len(visited) == n:
				break
	print(output_str)
	return
t = input()
for _ in range(int(t)):
	n = input()
	string = input()
	restore(string)


import math
t = int(input())
for g in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	cnt = [0 for i in range(n + 1)]
	Ans = []
	for i in range(2 * n):
		if cnt[A[i]] != 1:
			cnt[A[i]] += 1
			Ans.append(A[i])
	print(*Ans)


t = int(input())
while t > 0:
	l = int(input())
	n = list(map(int, input().split()))
	q = []
	for i in range(len(n)):
		if n[i] not in q:
			q.append(n[i])
	print(*q, sep=' ')
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	temp = []
	flag = 0
	for i in range(2 * n):
		if arr[i] not in ans:
			ans.append(arr[i])
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	s = set()
	for i in range(1, n + 1):
		s.add(i)
	r = ''
	for x in a:
		if x in s:
			r += str(x) + ' '
			s.remove(x)
	print(r[:-1])


for _ in range(int(input())):
	n = int(input())
	lx = list(map(int, input().split()))
	l1 = []
	for i in lx:
		if i not in l1:
			l1.append(i)
	print(' '.join(map(str, l1)))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	seen = set()
	res = []
	for i in l:
		if i not in seen:
			seen.add(i)
		else:
			res.append(i)
	print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = [0] * 51
	ans = []
	for j in l:
		if l1[j] == 0:
			ans.append(j)
			l1[j] += 1
	print(*ans)


t = int(input())
for n_t in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	counter = [2 for i in range(n + 1)]
	result = []
	for number in a:
		if counter[number] == 2:
			result.append(number)
			counter[number] -= 1
	print(' '.join((str(j) for j in result)))


for i in range(int(input())):
	ans = []
	tmp = []
	L = int(input())
	A = list(map(int, input().split()))
	for k in A:
		if k in tmp:
			tmp.remove(k)
		else:
			ans.append(k)
			tmp.append(k)
	print(' '.join(map(str, ans)))


t = int(input())
for _ in range(t):
	n = int(input())
	m = 2 * n
	list1 = list((int(m) for m in input().split()))
	list1.reverse()
	res = []
	while len(list1):
		x = list1[0]
		list1.pop(0)
		ind = list1.index(x)
		list1.pop(ind)
		res.append(x)
	res.reverse()
	print(*res)


def restored_permutation(arr):
	result = []
	for num in arr:
		if num not in result:
			result.append(num)
	return result
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(' '.join(map(str, restored_permutation(arr))))


def main():
	testCase = int(input())
	for _ in range(testCase):
		l = int(input())
		merge_per = list(map(int, input().split()))
		permutation = []
		while len(merge_per) > 0:
			permutation.append(merge_per[0])
			merge_per.remove(permutation[-1])
			merge_per.remove(permutation[-1])
		for i in permutation:
			print(i, end=' ')
		print()
main()


import sys
from math import floor as fl
from math import ceil as ce
from math import sqrt
cont = sys.stdin.readlines()
cont = [i.strip('\n').split() for i in cont]
num = int(cont.pop(0)[0])
nc = []
for i in range(num):
	nc.append(cont[:2])
	cont = cont[2:]
cont = nc
for i in cont:
	n = i.pop(0)
	i = [int(j) for j in i[0]]
	ret = []
	while len(i) != 0:
		first = i.pop(0)
		ret.append(first)
		i.remove(first)
	retstr = ''
	for j in ret:
		retstr += f'{j} '
	print(retstr)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	Set = set()
	ans = []
	for i in p:
		if i not in Set:
			Set.add(i)
			ans.append(i)
		if len(Set) == n:
			print(*ans, sep=' ')
			break


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in a:
		if i not in b:
			b.append(i)
			for j in range(a.count(i) // 2):
				print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = set(l)
	res = list()
	for i in l:
		if res.count(i) < l.count(i) // 2:
			res.append(i)
	print(*res)


t = int(input())
for cases in range(t):
	n = int(input())
	s = input()
	l = [int(item) for item in s.split(' ')]
	ans = []
	ans.append(str(l[0]))
	for i in range(1, 2 * n):
		if str(l[i]) not in ans:
			ans.append(str(l[i]))
	print(' '.join(ans))


from sys import *
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	for i in l:
		if i not in p:
			p.append(i)
	for i in p:
		print(i, end=' ')
	print('')


t = int(input())
while t > 0:
	n = int(input())
	z = int(n)
	b = list()
	f = input()
	g = f.split()
	for i in range(2 * n):
		if b.count(g[i]) == 0:
			b.append(g[i])
			n -= 1
			if n == 0:
				break
	for j in b:
		print(j, end=' ')
	t = t - 1


import math
import os
import random
import re
import sys
from collections import defaultdict
case = int(input())
for i in range(case):
	n = int(input())
	ara = [int(x) for x in input().split()]
	hasTaken = {}
	perm = []
	for item in ara:
		if item not in hasTaken:
			perm.append(item)
			hasTaken[item] = 1
	for item in perm:
		print(item, ' ', end='')
	print()


import sys, collections, math

def in_out():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	visit = set()
	res = []
	for ele in arr:
		if ele not in visit:
			visit.add(ele)
			res.append(ele)
	print(*res)


from math import *
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	for i in range(2 * n):
		if l[i] not in p:
			p.append(l[i])
		else:
			continue
	print(*p)


def main():
	t = int(input())
	for __ in range(t):
		n = int(input())
		num = set()
		a = list(map(int, input().split()))
		ans = []
		for i in a:
			if i not in num:
				num.add(i)
				ans.append(i)
		print(*ans)
main()


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	ans = []
	for i in l:
		if i not in ans:
			ans.append(i)
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	l = input()
	p = input().split()
	res = []
	for i in p:
		if i not in res:
			res.append(i)
	print(*res)


t = int(input())
for q in range(t):
	n = int(input())
	ent = list(map(int, input().split(' ')))
	sett = []
	for k in range(n * 2):
		if ent[k] not in sett:
			print(ent[k], end=' ')
			sett.append(ent[k])
	print()


def main():
	for _ in range(int(input())):
		n = int(input())
		a = [int(x) for x in input().split()]
		b = []
		for i in a:
			if i not in b:
				b.append(i)
		for j in b:
			print(j, end=' ')
		print(' ')
main()


def pizda(x):
	c = [0 for i in range(2 * x)]
	for i in range(2 * x):
		if c[b[i]] == 0:
			print(b[i], end=' ')
			c[b[i]] += 1
	print()
t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	pizda(n)


def unique(sequence):
	seen = set()
	return [x for x in sequence if not (x in seen or seen.add(x))]
t = int(input())
for i in range(t):
	n = int(input())
	a = unique(list(map(int, input().split())))
	for j in a:
		print(j, end=' ')
	print()


def fun():
	new = int(input())
	for i in range(new):
		yes = int(input())
		lo = list(map(int, input().split()))
		arr = []
		for y in lo:
			if y not in arr:
				arr.append(y)
				print(y, end=' ')
		print()
fun()


def getList(dict):
	list = []
	for key in dict.keys():
		list.append(key)
	return list
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	da = {}
	for item in l:
		if item in da:
			da[item] += 1
		else:
			da[item] = 1
	print(*getList(da))
	t = t - 1


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	a = l()
	answer = []
	s = set()
	for i in a:
		if i not in s:
			answer.append(i)
		s.add(i)
	outa(*answer)


for t in range(int(input())):
	n = int(input())
	listy = [int(k) for k in input().split()]
	new = []
	for ele in listy:
		if ele not in new:
			new.append(ele)
	print(*new)


def main(n, lst):
	res = []
	for i in lst:
		if i in res:
			continue
		res.append(i)
	return ' '.join(res)
for _ in range(int(input())):
	n = int(input())
	lst = input().split()
	print(main(n, lst))


for _ in range(int(input())):
	t = int(input())
	l = [int(x) for x in input().split()]
	k = 2 * t
	ll = []
	for i in range(k):
		if l[i] not in ll:
			ll.append(l[i])
	print(*ll)


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	stdin.readline()
	seen = set()
	sec = list(map(int, stdin.readline().split()))
	res = [x for x in sec if not (x in seen or seen.add(x))]
	print(*res)


n = int(input())
while n > 0:
	n -= 1
	_ = int(input())
	arr = input().split(' ')
	hmap = {}
	for i in arr:
		if hmap.get(i) == None:
			hmap[i] = 1
			print(i + ' ', end='')
	print()


t = int(input())
while t:
	n = int(input())
	m = [int(x) for x in input().split()]
	l = []
	for i in m:
		if i not in l:
			l.append(i)
	for i in l:
		print(i, end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	l = list(set(s))
	res = []
	for i in s:
		if i in l:
			res.append(i)
			l.remove(i)
	print(' '.join(map(str, res)))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = [0] * (max(arr) + 1)
	for i in arr:
		if brr[i] == 1:
			continue
		else:
			print(i, end=' ')
			brr[i] = 1
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = []
	second = -1
	for now in a:
		if second == -1 or second == len(ans):
			ans.append(now)
			second = len(ans) - 1
		elif ans[second] == now:
			second += 1
		else:
			ans.append(now)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l2 = []
	for x in l:
		if x not in l2:
			l2.append(x)
	for y in l2:
		print(y, end=' ')


for i in range(int(input())):
	n = int(input())
	dic = {}
	arr = list(map(int, input().split()))
	ans = []
	for k in arr:
		if dic.get(k, 0) == 0:
			dic[k] = 1
		else:
			ans.append(k)
	print(*ans)


n = int(input())
for i in range(n):
	input()
	r = {}
	l = []
	for x in input().split():
		if x not in r:
			l.append(x)
			r[x] = 1
	print(' '.join(l))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = []
	for j in a:
		if s.count(j) == 0:
			s.append(j)
	print(*s)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(int(input())):
	n = int(input())
	s = set()
	a = list(map(int, input().split()))
	for i in a:
		if i not in s:
			s.add(i)
			print(i, end=' ')
	print()


count = int(input())
for i in range(count):
	n = int(input())
	arr = list(map(lambda x: int(x), input().split(' ')))
	set_ = set(arr)
	num = len(set_)
	res = []
	for item in arr:
		if num == 0:
			break
		elif item not in res:
			res.append(item)
			num = -1
	print(*res)


for _ in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = []
	for i in range(0, n * 2):
		if a[i] != 0:
			res.append(a[i])
			for j in range(i + 1, n * 2):
				if a[j] == a[i]:
					a[j] = 0
	for i in range(0, n):
		print(res[i], end=' ')
	print()


t = int(input())
while t:
	n = int(input())
	l = [int(x) for x in input().split()]
	assert len(l) == 2 * n
	c = [0] * 2 * n
	o = []
	for i in range(2 * n):
		if c[i] == 1:
			o.append(str(l[i]))
			continue
		for j in range(i + 1, 2 * n):
			if l[i] == l[j]:
				c[j] = 1
	print(' '.join(o))
	t -= 1


inp = int(input())
for _ in range(inp):
	l = []
	inp1 = int(input())
	inp2 = list(map(int, input().split()))
	for num in inp2:
		if num not in l:
			l.append(num)
		if len(l) == inp1:
			break
	for x in l:
		print(x, end=' ')
	print(' ')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().rstrip().split()))[:2 * n]
	new = []
	for i in l:
		if i not in new:
			new.append(i)
			print(i, end=' ')
	print('\n')


import sys

def solve(a):
	out = []
	seen = {}
	for elem in a:
		if not elem in seen:
			seen[elem] = True
		else:
			out.append(elem)
	print(' '.join([str(x) for x in out]))
IN = [x.strip() for x in sys.stdin.readlines()]
T = int(IN[0])
cur = 1
for ti in range(T):
	n = int(IN[cur])
	a = [int(x) for x in IN[cur + 1].split(' ')]
	solve(a)
	cur += 2


(T,) = map(int, input().split())
for _ in range(T):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	d = dict()
	R = []
	for x in X:
		if x in d:
			continue
		d[x] = 1
		R.append(x)
	print(*R)


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	a = []
	b = []
	s = set()
	for i in range(2 * n):
		if arr[i] not in s:
			s.add(arr[i])
			a.append(arr[i])
		else:
			b.append(arr[i])
	print(*a)


t = int(input())
nums = []
for i in range(t):
	n = int(input())
	nums.append([int(x) for x in input().split()])
output = []
for num in nums:
	set1 = set(range(1, len(num) // 2 + 1))
	tmp = []
	for i in range(len(num)):
		if num[i] in set1:
			tmp.append(num[i])
			set1.remove(num[i])
	print(*tmp)


T = int(input())
for i in range(T):
	x = int(input())
	lst = []
	y = list(map(int, input().split()))
	for k in y:
		if lst.count(k) == 0:
			lst.append(k)
	for k in lst:
		print(k, end=' ')
	print()
	lst = []


for i in range(int(input())):
	n = int(input())
	saida = []
	p = [saida.append(int(x)) for x in input().split() if int(x) not in saida and len(saida) != n]
	print(*saida, sep=' ')


def nod(a, b):
	while a != b:
		(a, b) = (max(a, b), min(a, b))
		if a % b == 0:
			a -= (a // b - 1) * b
		else:
			a -= a // b * b
	return a
for t in range(int(input())):
	n = int(input())
	s = set()
	a = []
	for e in [int(x) for x in input().split()]:
		if not e in s:
			a.append(e)
			s.add(e)
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	list1 = list(map(int, input().strip().split()))
	ans = []
	for val in list1:
		if val not in ans:
			ans.append(val)
	for val in ans:
		print(val, end=' ')
	print()


t = int(input())
for i in range(t):
	a = int(input())
	b = [int(s) for s in input().split()]
	c = []
	for k in b:
		if c.count(k) == 0:
			c.append(k)
	print(*c)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i not in d:
			d[i] = 1
	for (key, value) in d.items():
		print(key, end=' ')
	print()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for i in range(n * 2):
		if a[i] not in p:
			p.append(a[i])
	print(' '.join([str(i) for i in p]))


def f():
	t = int(input())
	ns = []
	arr = []
	for _ in range(t):
		ns.append(int(input()))
		arr.append(list(input().split()))
	for i in range(len(arr)):
		lis = arr[i]
		(s, ans) = (set(), [])
		for ele in lis:
			if ele in s:
				continue
			s.add(ele)
			ans.append(ele)
		ans = ' '.join(ans)
		print(ans)
f()


t = int(input())
i = 0
while i < t:
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	s = set()
	for x in arr:
		if x in s:
			pass
		else:
			s.add(x)
			res.append(x)
	print(*res)
	i = i + 1


t = int(input())
for i in range(t):
	n = int(input())
	inp = [int(j) for j in input().split()]
	freq = [0 for i in range(100)]
	res = []
	for k in range(2 * n):
		freq[inp[k]] = freq[inp[k]] + 1
		if freq[inp[k]] == 1:
			res.append(inp[k])
	for num in res:
		print(num, end=' ')
	print()


from sys import stdin
T = int(stdin.readline())
li = []
for _ in range(T):
	garb = stdin.readline()
	li = [int(x) for x in stdin.readline().split()]
	se = set(li)
	for elem in li:
		if elem in se:
			se.remove(elem)
			print(elem, end=' ')
	print()


def Print(s):
	for i in s:
		print(i, end=' ')
	print()
n = int(input())
for _ in range(n):
	l = int(input())
	a = list(map(int, input().split()))
	b = sorted(set(a), key=a.index)
	Print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	s = set([])
	for i in a:
		s.add(i)
	for i in sorted(s, key=a.index):
		print(i, end=' ')
	print()


for t in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	count = 0
	x = []
	x1 = set()
	i = 0
	while count < n:
		if not a[i] in x1:
			count += 1
			x.append(a[i])
			x1.add(a[i])
		i += 1
	print(' '.join([str(i) for i in x]))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(1, n + 1):
		d['{}'.format(i)] = a.index(i)
	ans = {k: v for (k, v) in sorted(d.items(), key=lambda item: item[1])}
	print(*ans.keys())


tc = int(input())
for _ in range(tc):
	n = int(input())
	a = list(map(int, input().split()))
	mark = [False] * n
	for val in a:
		if not mark[val - 1]:
			print(val, end=' ')
			mark[val - 1] = True
	print()


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = [int(i) for i in stdin.readline().split(' ')]
	dic = {}
	s = ''
	for i in a:
		if i not in dic:
			dic[i] = 1
			s += str(i) + ' '
		else:
			dic[i] += 1
			if dic[i] % 2 != 0:
				s += str(i) + ' '
	print(s[:-1])


t = int(input())
for i in range(t):
	nonsense = input()
	n = str(input())
	l = list(map(int, n.split(' ')))
	k = l[0]
	r = []
	while len(l) > 2:
		r.append(l[0])
		l.remove(k)
		l.remove(k)
		k = l[0]
	k = l[0]
	r.append(l[0])
	m = ' '.join(map(str, r))
	print(m)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return list(map(int, input().split()))
t = inp()
for i in range(t):
	n = inp()
	a = inlt()
	seen = set()
	res = []
	for _a in a:
		if _a not in seen:
			res.append(_a)
		seen.add(_a)
	print(' '.join(map(str, res)))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	for elm in arr:
		if elm not in ans:
			ans.append(elm)
	for elm in ans:
		print(elm, end=' ')
	print()


for iota in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	ans = set()
	fin = []
	for i in num:
		if i in ans:
			continue
		else:
			ans.add(i)
			fin.append(i)
	print(*fin)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	k = max(nums)
	indices = [nums.index(n) for n in range(1, k + 1)]
	ans = [n for (i, n) in sorted(zip(indices, range(1, k + 1)))]
	print(*ans)


def password(a, size):
	res = []
	for i in a:
		if res.count(i) == 0:
			res.append(i)
		if len(res) == size:
			printList(res)
			return

def printList(a):
	for i in a:
		print(i, end=' ')
	print()
tests = int(input())
for i in range(tests):
	size = int(input())
	a = list(map(int, input().split()))
	password(a, size)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	a = {}
	l1 = []
	for i in range(len(l)):
		if l[i] not in a:
			a[l[i]] = 0
		a[l[i]] += 1
	for i in a:
		if a[i] % 2 == 0:
			l1.append(i)
	print(*l1, sep=' ')


t = int(input())
while t > 0:
	n = int(input())
	s = list(input().split())
	f = list(dict.fromkeys(s))
	print(*f)
	t -= 1


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [True] * (n + 1)
	ans = []
	for i in range(2 * n):
		if cnt[a[i]]:
			ans.append(a[i])
			cnt[a[i]] = False
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


def seq_finder(array, n):
	index_track = {}
	i = 0
	for item in array:
		if len(index_track) <= n and item not in index_track:
			index_track[item] = i
			i += 1
	return index_track
T = int(input())
for _ in range(T):
	n = int(input())
	array = list(map(int, input().split()))
	index_track = seq_finder(array, n)
	ans = [None] * n
	for (item, index) in index_track.items():
		ans[index] = item
	for item in ans:
		print(item, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	ls = [int(i) for i in input().split()]
	st_ls = set()
	ans = []
	for num in ls:
		if num not in st_ls:
			st_ls.add(num)
			ans.append(num)
	print(*ans)


for i in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split(' ')))
	new = []
	for i in range(2 * n):
		if ar[i] not in new:
			new.append(ar[i])
	print(' '.join(map(str, new)))


import math
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	(first, second) = (list(), list())
	for i in range(2 * n):
		if a[i] in first:
			second.append(a[i])
		else:
			first.append(a[i])
	print(*first)


import math, bisect, heapq, collections, itertools, datetime, functools, sys, os
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for testcase in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	single = set()
	for ele in arr:
		if len(ans) == n:
			break
		if ele not in single:
			ans.append(ele)
			single.add(ele)
	print(*ans)


def main(args):
	t = int(input())
	for i in range(t):
		n = int(input())
		m = [0] * n
		j = []
		val = list(map(int, input().split()))
		for z in val:
			if m[z - 1] == 0:
				j.append(z)
				m[z - 1] = 1
		for i in j:
			print(i, end=' ')
		print()
import sys
sys.exit(main(sys.argv))


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	d = []
	done = []
	for j in a:
		if j not in done:
			d.append(j)
			done.append(j)
	ans.append(d)
for i in ans:
	print(*i)


n = int(input())
for _ in range(n):
	k = int(input())
	l = list(map(int, input().split()))
	m = []
	for i in range(k * 2):
		if l[i] not in m:
			m.append(l[i])
		else:
			pass
	for j in m:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	ans = []
	for i in a:
		if i in d:
			if d[i] == 0:
				d[i] = 1
			else:
				ans.append(i)
				d[i] = 0
		else:
			d[i] = 1
	print(*ans)


import sys
input = sys.stdin.readline

def readstr():
	return input().strip()

def readint():
	return int(input())

def readnums():
	return map(int, input().split())

def readstrs():
	return input().split()

def main():
	N = readint()
	for _ in range(N):
		n = readint()
		a = list(readnums())
		d = {i: 0 for i in set(a)}
		ans = list()
		for aa in a:
			d[aa] += 1
			if d[aa] == 2:
				ans.append(aa)
		print(' '.join(map(str, ans)))
main()


t = int(input())
for t in range(t):
	l = []
	fin = []
	s = ''
	n = int(input())
	x = input()
	l = x.split()
	for i in l:
		if i not in fin:
			fin.append(i)
			s = s + i + ' '
	print(s)


t = int(input())
while t > 0:
	n = int(input())
	inp = list(map(int, input().split()))
	lst = []
	fn = lst.append
	for i in range(n * 2):
		if inp[i] not in lst:
			fn(inp[i])
	out = ' '.join([str(x) for x in lst])
	print(out)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr1 = []
	j = 0
	while len(arr1) < n:
		if arr[j] not in arr1:
			arr1.append(arr[j])
			j += 1
		else:
			j += 1
	for k in arr1:
		print(k, end=' ')
	print()


r = int(input())
for i in range(r):
	n = int(input())
	num = input()
	list = [int(i) for i in num.split()]
	l = []
	for i in list:
		if i not in l:
			l.append(i)
	for i in l:
		print(i, end=' ')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		d = {}
		ans = []
		for i in a:
			if i not in d:
				d[i] = 1
				ans.append(i)
		wia(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	l1 = []
	for j in l:
		if s == n:
			break
		if j not in l1:
			l1.append(j)
			s += 1
	for j in range(len(l1)):
		if j == len(l1) - 1:
			print(l1[j])
		else:
			print(l1[j], end=' ')


def printt(arr, n):
	s = dict()
	for i in range(n):
		if arr[i] not in s.keys():
			s[arr[i]] = arr[i]
			print(arr[i], end=' ')
	print()
test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	b = printt(arr, n * 2)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
from bisect import bisect_left, bisect_right
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set()
	ans = []
	for i in l:
		if i not in s:
			ans.append(i)
		s.add(i)
	print(*ans)


for i in range(int(input())):
	res_len = int(input())
	l = list(map(int, input().split()))
	dic = {}
	for i in l:
		if i in dic:
			dic[i] += 1
		else:
			dic[i] = 1
	s = ''
	for i in dic:
		s = s + str(i) + ' '
	print(s)


n = int(input())
for k in range(n):
	t = int(input())
	va = list(map(int, input().split()))
	a = []
	for k in va:
		if k not in a:
			a.append(k)
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = list(set(l))
	d = {}
	for i in range(len(s)):
		d[s[i]] = 0
	ans = []
	for i in range(len(l)):
		if not d[l[i]]:
			d[l[i]] = 1
			ans.append(l[i])
	for i in range(len(ans)):
		if i != len(ans) - 1:
			print(ans[i], end=' ')
		else:
			print(ans[-1])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = []
	for i in a:
		if i not in ans:
			ans.append(i)
	print(*ans)


for i in range(int(input())):
	m = int(input())
	l = [int(x) for x in input().split()]
	dic = {}
	n = 0
	k = []
	for i in l:
		if n < m:
			if str(i) in dic:
				continue
			else:
				dic[str(i)] = 1
				k.append(i)
				n += 1
				continue
		else:
			break
	for i in k[:len(k) - 1]:
		print(i, end=' ')
	print(k[len(k) - 1])


for i in range(int(input())):
	n = int(input())
	p = []
	arr = list(map(int, input().split()))
	for num in arr:
		if num not in p:
			p.append(num)
	for num in p:
		print(num, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	t = []
	visited = [False] * (len(a) + 1)
	for i in range(len(a)):
		if not visited[a[i]]:
			t.append(a[i])
			visited[a[i]] = True
	for i in range(n):
		print(t[i], end=' ')
	print()


n = int(input())
while n:
	num = int(input())
	x = input()
	lst = x.split(' ')
	l = len(lst)
	num_lst = []
	for nn in lst:
		num_lst.append(eval(nn))
	found = []
	for i in range(0, num + 1):
		found.append(False)
	ans_list = []
	for elem in num_lst:
		if found[elem] == False:
			found[elem] = True
			ans_list.append(elem)
	for x in ans_list:
		print(x, end='')
		print(' ', end='')
	n = n - 1


from sys import stdin, stdout
import sys
INF = 100000000000.0
import bisect

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
from collections import defaultdict
import math
for t in range(int(stdin.readline())):
	n = get_int()
	a = get_array()
	ans = []
	for i in a:
		if i not in ans:
			ans.append(i)
	print(*ans)


import collections
t = int(input())
for q in range(0, t):
	n = int(input())
	a = [int(i) for i in input().split()]
	d = {}
	ans = []
	for i in range(0, len(a)):
		if d.get(a[i]) == None:
			d[a[i]] = 1
			ans.append(a[i])
	print(*ans)


from sys import stdin, stdout
import math
import heapq
t = 1

def aint():
	return int(input().strip())

def lint():
	return list(map(int, input().split()))

def fint():
	return list(map(int, stdin.readline().split()))

def main():
	n = aint()
	l = lint()
	s = set()
	for i in l:
		if i not in s:
			print(i, end=' ')
			s.add(i)
	print('')
	return
t = int(input())
for i in range(t):
	main()


test = int(input())
for t in range(test):
	num = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(len(a)):
		if a[i] in b:
			continue
		else:
			b.append(a[i])
	print(*b)


loop = int(input())
lif = []
for i in range(loop):
	n = int(input())
	per = []
	mix = list(map(int, input().split(' ')))
	for j in mix:
		if per.count(j) == 0:
			per.append(j)
	lif.append(per)
for i in lif:
	print(*i)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	visit = [False] * n
	ans = []
	for i in range(2 * n):
		if visit[L[i] - 1] == False:
			ans.append(L[i])
			visit[L[i] - 1] = True
	print(*ans)


for i in range(int(input())):
	a = int(input())
	b = list(map(str, input().split()))
	result = []
	for j in b:
		if j not in result:
			result.append(j)
	print(' '.join(result))


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	k = []
	for i in l:
		if i in k:
			pass
		else:
			k.insert(len(k), i)
			if len(k) == n:
				break
	for i in k:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	num = []
	for j in lst:
		if j not in num:
			num.append(j)
	print(*num)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	v = [0] * (n + 1)
	x = []
	for i in a:
		if v[i] == 1:
			continue
		v[i] = 1
		x.append(i)
	print(*x)


from collections import Counter

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = list(map(int, input().split()))
		c = Counter(A)
		ans = []
		B = set(A)
		for a in A:
			if c[a] > 0:
				c[a] -= 2
				ans.append(str(a))
		print(' '.join(ans))
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	vis = []
	for i in range(2 * n):
		if a[i] in vis:
			continue
		else:
			vis.append(a[i])
	print(*vis)


for test in range(int(input())):
	n = int(input())
	a = input().split()
	ans = []
	for i in range(2 * n):
		if a[i] not in ans:
			ans.append(a[i])
			print(int(a[i]), end=' ')
		if len(ans) == n:
			break
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	temp = set()
	ans = []
	for j in a:
		if j in temp:
			continue
		else:
			ans.append(j)
			temp.add(j)
	print(*ans)


from sys import *
t = int(stdin.readline())
while t > 0:
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	s = set()
	for i in range(2 * n):
		if arr[i] not in s:
			s.add(arr[i])
			print(arr[i], end=' ')
		else:
			continue
	print()
	t -= 1


for item in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	fin = []
	for i in lst:
		if i in fin:
			continue
		else:
			fin.append(i)
	for i in fin:
		print(i, end=' ')


t = int(input(''))
for i in range(0, t):
	n = int(input(''))
	st = list(map(int, input('').split()))
	s = []
	for j in range(0, len(st)):
		if st[j] not in s:
			s.append(st[j])
		else:
			continue
		if len(s) == len(st) // 2:
			break
	for j in range(0, len(s)):
		print(s[j], end=' ')


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	i = 0
	checked = {}
	perm = []
	for i in range(2 * n):
		if checked.get(arr[i], None) == None:
			perm.append(arr[i])
			checked[arr[i]] = 1
	print(*perm)


def pd(arr, n):
	for i in range(0, n):
		d = 0
		for j in range(0, i):
			if arr[i] == arr[j]:
				d = 1
				break
		if d == 0:
			print(arr[i], end=' ')
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	pd(l, 2 * n)
	print()


from array import *
cases = int(input(''))
result = []
for c in range(cases):
	output = []
	output1 = []
	indexes = []
	size = int(input(''))
	x = input('').split()
	for i in range(len(x)):
		output1.append(int(x[i]))
	m = set(output1)
	m = list(m)
	for i in m:
		if i in output1:
			z = output1.index(i)
			indexes.append(z)
	indexes.sort()
	for i in indexes:
		output.append(output1[i])
	result.insert(c, output)
for c in range(cases):
	print(*result[c])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = input().split()
	s = set()
	for i in range(2 * n):
		arr[i] = int(arr[i])
	for i in range(2 * n):
		if arr[i] not in s:
			print(arr[i], end=' ')
			s.add(arr[i])
	print('')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	l = int(input())
	m = list(map(int, input().split()))
	m = m[::-1]
	uni = []
	for el in m:
		if el not in uni:
			uni.append(el)
	uni = uni[::-1]
	print(*uni)


for h in range(int(input())):
	n = int(input())
	q = list(map(int, input().strip().split()))
	arr = []
	seti = set()
	for i in q:
		if i not in seti:
			seti.add(i)
			arr.append(i)
	print(*arr)


for t in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	s = set()
	for i in range(1, n + 1):
		s.add(i)
	p = []
	for a in A:
		if a in s:
			p.append(a)
			s.remove(a)
	for e in p:
		print(e, end=' ')
	print()


t = int(input())
for z in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arrf = []
	for i in range(2 * n):
		if arr[i] not in arrf:
			arrf.append(arr[i])
	print(*arrf)


from collections import OrderedDict

def multiple_input():
	return map(int, input().split())

def list_input():
	return list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	a = list_input()
	l = list(OrderedDict.fromkeys(a))
	print(*l)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = []
	for i in l:
		if i not in k:
			k.append(i)
			n -= 1
		if n == 0:
			break
	print(*k)


t = int(input())
for T in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	vis = [False] * (n + 1)
	ans = [0] * n
	itr = 0
	for i in l:
		if not vis[i]:
			vis[i] = True
			ans[itr] = i
			itr += 1
	print(*ans)


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	set1 = list(range(1, n + 1))
	set2 = []
	for (count, i) in enumerate(arr):
		if i in set1:
			set1.remove(i)
			set2.append(i)
	ans.append(set2)
for i in ans:
	for j in i:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	final = []
	per = [int(i) for i in input().split()]
	for i in per:
		if i not in final:
			final.append(i)
	print(*final)


def solve():
	n = int(input())
	lst = list(map(int, input().split()))
	ans = []
	for i in range(2 * n):
		if lst[i] not in ans:
			ans.append(lst[i])
	print(*ans)
t = int(input())
for i in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	ans = []
	s = set()
	for i in range(2 * n):
		if lst[i] not in s:
			ans.append(lst[i])
			s.add(lst[i])
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	li = [int(x) for x in input().split()]
	output = {}
	for i in li:
		if i not in output:
			output[i] = output.get(i, 0) + 1
		else:
			pass
	for (i, v) in output.items():
		print(i, end=' ')


t = int(input())
while t > 0:
	n = int(input())
	A = list(map(str, input().split(' ')))
	m = []
	for i in range(len(A)):
		if A[i] not in m:
			m.append(A[i])
	print(' '.join(m))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	main = []
	for i in lst:
		if i not in main:
			main.append(i)
	print(*main)


def do():
	n = int(input())
	dat = list(map(int, input().split()))
	res = []
	used = dict()
	for i in range(n * 2):
		if dat[i] not in used:
			used[dat[i]] = True
			res.append(dat[i])
	print(' '.join(list(map(str, res))))
q = int(input())
for _ in range(q):
	do()


t = int(input())
for i in range(0, t):
	n = int(input())
	flag = [False for j in range(1, n + 1)]
	p = input().split()
	for j in range(0, 2 * n):
		p[j] = int(p[j])
	output = []
	for j in p:
		if flag[j - 1]:
			continue
		flag[j - 1] = True
		output.append(j)
	for x in output:
		print(x, end=' ')
	print()


t = int(input())
for i in range(t):
	l = int(input())
	l1 = list()
	l1 = [int(x) for x in input().split()]
	l2 = list()
	for j in range(2 * l):
		if l1[j] in l2:
			continue
		else:
			l2.append(l1[j])
			print(l1[j], end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lst = []
	ct = 0
	for i in arr:
		if i not in lst:
			lst.append(i)
			ct += 1
		if ct == n:
			break
	for i in lst:
		print(i, end=' ')
	print()


p = []
n = int(input())
for x in range(n):
	size = int(input())
	lis = [int(x) for x in input().split()]
	for x in lis:
		if x not in p:
			p.append(x)
	print(*p, sep=' ')
	p = []


t = int(input())
for i in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	di = {}
	c = []
	for i in li:
		if i not in di:
			print(i, end=' ')
			di[i] = 1
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	val = l[0]
	j = 1
	d = {val: True}
	for i in range(1, 2 * n):
		if d.get(l[i], None) is None:
			l[j] = l[i]
			j += 1
			d[l[i]] = True
	print(' '.join(map(str, l[:n])))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	n = int(ri())
	a = Ri()
	s = set([i for i in range(1, n + 1)])
	ans = []
	for i in a:
		if i in s:
			ans.append(i)
			s.remove(i)
	print(*ans)


def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	w = {}
	for i in a:
		if i in w:
			continue
		w[i] = 1
	return ' '.join([str(i) for i in list(w)])
t = int(input())
ans = []
while t:
	ans.append(str(solve()))
	t -= 1
print('\n'.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	vis = [0] * (n + 1)
	a = list(map(int, input().split()))
	for i in a:
		if vis[i] == 0:
			print(i, end=' ')
			vis[i] += 1
	print()


for i in range(int(input())):
	input()
	l = input().split()
	s = set()
	for j in l:
		if j not in s:
			print(j, end=' ')
			s.add(j)


def Sequence(String, Length):
	Sequence = String.split(' ')
	Permutation = []
	for i in range(len(Sequence)):
		Sequence[i] = int(Sequence[i])
	for i in range(Length):
		Current = Sequence[0]
		Permutation.append(Current)
		Sequence.pop(0)
		for j in range(len(Sequence)):
			if Sequence[j] == Current:
				Remove = j
		Sequence.pop(Remove)
	New = ''
	for i in range(len(Permutation) - 1):
		New = New + str(Permutation[i]) + ' '
	New = New + str(Permutation[len(Permutation) - 1])
	return New
Trials = int(input(''))
for i in range(Trials):
	Length = int(input(''))
	String = input('')
	print(Sequence(String, Length))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	sz = len(arr)
	var = []
	for j in range(sz):
		if arr[j] not in var:
			var.append(arr[j])
		if len(var) == sz // 2:
			break
	for j in range(sz // 2):
		print(var[j], end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0] * n
	for x in a:
		if d[x - 1] == 0:
			d[x - 1] = 1
			print(x, end=' ')
	print()


def perm(a, n):
	p = []
	for i in a:
		if i not in p:
			p.append(i)
	for i in p:
		print(i, end=' ')
	print()
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	perm(a, n)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	res = []
	for i in a:
		if i not in d:
			d[i] = True
			res.append(i)
	print(*res)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n * n]
	p = []
	for i in range(len(a)):
		if a[i] not in p:
			p.append(a[i])
	print(*p)


t = int(input())
for _ in range(t):
	n = int(input())
	per = list(map(int, input().split()))
	s = set()
	ans = ''
	for i in range(n * 2):
		if per[i] not in s:
			s.add(per[i])
			ans += str(per[i]) + ' '
	print(ans)


for i in range(int(input())):
	B = []
	n = int(input())
	A = list(map(int, input().split()))
	for j in A:
		if j not in B:
			B.append(j)
	for j in B:
		print(j, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	for j in range(2 * n):
		if l[j] in s:
			print(l[j], end=' ')
			s.remove(l[j])
	print()


test = int(input())
for t in range(test):
	n = int(input())
	p = list(map(int, input().split()))
	print(*list(dict.fromkeys(p)))


input_length = int(input())
while input_length != 0:
	num_perm = int(input())
	num_string = str(input())
	num_string = num_string.split()
	input_length -= 1
	num_string = [int(x) for x in num_string]
	my_array = []
	while num_perm != 0:
		my_array.append(num_string[0])
		varnow = num_string[0]
		del num_string[0]
		num_string.remove(varnow)
		num_perm -= 1
	for value in my_array:
		print(value, end=' ')
	print()


t = int(input())
for i in range(t):
	y = int(input())
	a = dict.fromkeys(map(int, input().split()))
	print(*a)


from collections import defaultdict

def solve(n, a):
	counts = defaultdict(list)
	for (i, x) in enumerate(a):
		counts[x].append(i)
	res = []
	for (v, m) in counts.items():
		res.append(v)
	return res
t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	print(*solve(n, a))
	t -= 1


import math
while True:
	try:
		T = int(input())
		for t in range(T):
			n = int(input())
			vis = [0 for i in range(55)]
			ans = [0 for i in range(55)]
			cnt = 0
			a = list(map(int, input().split()))
			for i in range(2 * n):
				if vis[a[i]] == 0:
					vis[a[i]] = 1
					ans[cnt] = a[i]
					cnt = cnt + 1
			for i in range(cnt):
				print(ans[i], end=' ')
			print('')
	except EOFError:
		break


t = int(input())
for _ in range(t):
	n = int(input())
	line = list(map(int, input().split()))
	used = {}
	result = []
	for element in line:
		if element not in used:
			used[element] = True
			result.append(element)
	print(*result)


t = int(input())
for _ in range(t):
	k = input()
	arr = input().split()
	for (i, elem) in enumerate(arr):
		if elem not in arr[:i]:
			print(elem, end=' ')
	print()


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	st = ''
	for elem in arr:
		if elem not in ans:
			st += str(elem) + ' '
			ans.append(elem)
	print(st)
	return
t = int(input())
for i in range(t):
	solve()


tcase = int(input())
for i in range(tcase):
	int_n = int(input())
	sysinp = list(input())
	a = []
	redunt = ''
	for item in range(len(sysinp)):
		if sysinp[item] == ' ':
			a.append(int(redunt))
			redunt = ''
		else:
			redunt += sysinp[item]
			if item == len(sysinp) - 1:
				a.append(int(redunt))
	outlist = []
	for val in a:
		if len(outlist) >= int_n:
			break
		if val in outlist:
			continue
		else:
			outlist.append(val)
	listremo = ''
	for i in outlist:
		if listremo == '':
			listremo += str(i)
		else:
			listremo += ' ' + str(i)
	print(listremo)


t = int(input())
n_lists = []
for i in range(t):
	n = int(input())
	nlst = [int(ip) for ip in input().split()]
	n_lists.append((n, nlst))
for n_list in n_lists:
	(n, nlst) = n_list
	nr = list(range(1, n + 1))
	answer = []
	for z in nlst:
		if z in nr:
			answer.append(z)
			nr.remove(z)
	print(*answer, sep=' ')


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	u = [l[0]]
	for i in range(1, len(l)):
		if l[i] not in u:
			u.append(l[i])
	for i in u:
		print(i, end=' ')
	print()


n = int(input())
for _ in range(n):
	m = int(input())
	a = list(map(int, input().split(' ')))
	ap = []
	for e in a:
		if e not in ap:
			ap.append(e)
		else:
			pass
	for e in ap:
		print(e, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	v = list(map(int, input().split()))
	vv = []
	for j in range(2 * n):
		if v[j] not in vv:
			vv.append(v[j])
	print(*vv)


for t in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	p = [a[0]]
	for i in range(1, 2 * n):
		if a[i] not in p:
			p.append(a[i])
	print(*p)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	p = list(dict.fromkeys(a))
	for j in range(len(p)):
		print(p[j], end=' ')
	print(sep='\n')


for _ in range(int(input())):
	n = int(input())
	mass = [int(i) for i in input().split()]
	temp = set()
	ans = []
	for i in mass:
		if i not in temp:
			temp.add(i)
			ans.append(i)
	print(*ans)


t = int(input())
for _ in range(0, t):
	_ = input()
	x = input().split()
	f = []
	a = []
	for i in x:
		if i in f:
			continue
		else:
			f.append(i)
			a.append(i)
	print(' '.join(a))


def solve(l):
	taken = [False] * len(l)
	for (i, x) in enumerate(l):
		if not taken[i]:
			yield x
			for (j, y) in enumerate(l):
				if x == y:
					taken[j] = True
for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	print(*solve(l))


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = input().split()
		seen = set()
		p1 = []
		p2 = []
		for i in a:
			if i in seen:
				p2.append(i)
			else:
				p1.append(i)
			seen.add(i)
		print(' '.join(p1))
main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	visit = [False for i in range(n + 1)]
	res = [arr[0]]
	visit[arr[0]] = True
	for k in range(1, len(arr)):
		if not visit[arr[k]]:
			visit[arr[k]] = True
			res.append(arr[k])
	print(*res)


def solve1():
	n = int(input())
	arr = [int(i) for i in input().split()]
	dct = {}
	for i in arr:
		dct[i] = None
	print(*dct)
for _ in range(int(input())):
	solve1()


from sys import stdin

def r():
	return stdin.readline().strip()

def r_t(tp):
	return map(tp, r().strip().split())

def r_a(tp):
	return list(r_t(tp))

def solve(A, N):
	(ans, vis) = (list(), [0 for _ in range(N * 2 + 1)])
	for x in A:
		if not vis[x]:
			ans.append(x)
		vis[x] = 1
	return ans

def main():
	cases = int(r())
	for case in range(cases):
		N = int(r())
		X = list(r_t(int))
		print(*solve(X, N))
main()


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	n = iinput()
	a = get_list()
	done = set()
	ans = []
	for i in range(2 * n):
		if a[i] in ans:
			pass
		else:
			ans.append(a[i])
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	length = 2 * n
	result = []
	cnt = 0
	arr = list(map(int, input().split()))
	for j in arr:
		if j not in result:
			result.append(j)
			cnt = cnt + 1
		if cnt == n:
			for l in result:
				print(l, end=' ')
			break


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	t = set()
	r = []
	for i in arr:
		if not i in t:
			r.append(i)
			t.add(i)
	print(' '.join(map(str, r)))


t = int(input())
for i in range(t):
	n = int(input())
	array = input().split()
	p = []
	for inp in array:
		if inp not in p:
			p.append(inp)
	print(*p)


t = int(input())
for s in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	visited = [True for i in range(0, n + 1)]
	i = 2 * n - 1
	rama = []
	while i >= 0:
		if visited[a[i]] == True:
			rama.append(a[i])
			visited[a[i]] = False
		i -= 1
	m = n - 1
	i = m
	while i >= 0:
		print(rama[i], end=' ')
		i -= 1
	print()


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	s = []
	s = set(s)
	for i in l:
		if i not in s:
			print(i, end=' ')
			s.add(i)
	print()


t = int(input())
while t:
	n = int(input())
	(b, y) = ([0] * 2 * n, 0)
	a = list(map(int, input().split()))
	for x in range(2 * n):
		if b.count(a[x]) == 0:
			b[y] = a[x]
			y += 1
	for x in range(n):
		print(b[x], end=' ')
	print()
	t -= 1


n = int(input())
for i in range(n):
	x = int(input())
	y = input().split()
	l = []
	for j in y:
		if j not in l:
			l.append(j)
	for j in l:
		print(j, end=' ')
	print()


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()][:2 * n]
	d = Counter(l)
	print(*d.keys())


n = int(input())
for i in range(n):
	length = int(input())
	l = list(map(int, input().split()))
	ans = []
	for i in l:
		if i not in ans:
			ans.append(i)
	print(*ans)


t = int(input())
ans = []
for kit in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	have = [False] * n
	p = []
	for i in a:
		if not have[i - 1]:
			p += [i]
			have[i - 1] = True
	ans += [p]
for i in ans:
	print(*i)


n = int(input())
for i in range(n):
	ans = list()
	b = input()
	a = input()
	l = a.split(' ')
	for i in range(len(l)):
		l[i] = int(l[i])
	for j in l:
		if j not in ans:
			ans.append(j)
			print(j, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	d = {}
	for i in x:
		if i not in d:
			d[i] = 0
	for i in d:
		print(i, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	ip = list(map(int, input().split()))
	count = []
	for j in ip:
		if j not in count:
			count.append(j)
	for j in count:
		print(j, end=' ')
	print()


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
from collections import Counter
for case in range(itg()):
	n = itg()
	arr = tuple(mpint())
	counter = Counter(arr)
	ans = []
	for a in arr:
		if counter[a] & 1 ^ 1:
			ans.append(a)
		counter[a] -= 1
	print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	n = int(input())
	vals = list(map(int, input().split()))
	setty = set([])
	outy = []
	for s in range(len(vals)):
		if len(setty) >= n:
			break
		elif not vals[s] in setty:
			setty.add(vals[s])
			outy.append(vals[s])
	print(*outy)


def splitArray(given):
	newSize = len(given) / 2
	newValues = []
	valueExist = False
	for i in range(0, len(given)):
		if len(newValues) == 0:
			newValues.append(given[i])
		else:
			for j in range(0, len(newValues)):
				if given[i] == newValues[j]:
					valueExist = True
			if not valueExist:
				newValues.append(given[i])
		valueExist = False
	if len(newValues) == len(given) / 2:
		return newValues
numoftests = int(input())
tests = []
testsSpl = []
given_arr = []
first_arr = []
second_arr = []
for i in range(0, numoftests):
	arrsize = int(input()) * 2
	given_arr.append(input())
	given_arrMod = given_arr[i].split()
	needed = splitArray(given_arrMod)
	values = ''
	if len(needed) == 0:
		print('A7a')
	else:
		for k in range(0, len(needed)):
			values = values + ' ' + str(needed[k])
		print(values.lstrip())


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	vis = [False] * (n + 1)
	p = []
	for i in a:
		if vis[i]:
			continue
		vis[i] = True
		p.append(i)
	print(*p)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = []
	i = 0
	j = 0
	while i != len(l) - 1 and j != n:
		if l[i] not in k:
			k.append(l[i])
			j += 1
		i += 1
	print(*k)


t = int(input())
for i in range(t):
	x = int(input())
	temp = []
	arr = list(map(int, input().split()))
	for i in arr:
		if i not in temp:
			temp.append(i)
			print(i, end=' ')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(*dict.fromkeys(a))


from math import inf, log2

class SegmentTree:

	def __init__(self, array, func=max):
		self.n = len(array)
		self.size = 2 ** (int(log2(self.n - 1)) + 1) if self.n != 1 else 1
		self.func = func
		self.default = 0 if self.func != min else inf
		self.data = [self.default] * (2 * self.size)
		self.process(array)

	def process(self, array):
		self.data[self.size:self.size + self.n] = array
		for i in range(self.size - 1, -1, -1):
			self.data[i] = self.func(self.data[2 * i], self.data[2 * i + 1])

	def query(self, alpha, omega):
		if alpha == omega:
			return self.data[alpha + self.size]
		res = self.default
		alpha += self.size
		omega += self.size + 1
		while alpha < omega:
			if alpha & 1:
				res = self.func(res, self.data[alpha])
				alpha += 1
			if omega & 1:
				omega -= 1
				res = self.func(res, self.data[omega])
			alpha >>= 1
			omega >>= 1
		return res

	def update(self, index, value):
		index += self.size
		self.data[index] = value
		index >>= 1
		while index:
			self.data[index] = self.func(self.data[2 * index], self.data[2 * index + 1])
			index >>= 1
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	st = set()
	b = []
	for i in range(len(a)):
		if a[i] not in st:
			st.add(a[i])
			b += [a[i]]
		if len(st) == n:
			break
	print(*b)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set()
	ans = []
	for i in range(len(l)):
		if l[i] not in s:
			ans.append(l[i])
			s.add(l[i])
	for k in ans:
		print(k, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = [int(i) for i in input().split()]
	l2 = []
	for i in range(len(l1)):
		if l1[i] not in l2:
			l2.append(l1[i])
	for i in range(n - 1):
		print(l2[i], end=' ')
	print(l2[n - 1])


import sys
from collections import defaultdict

def get_ints():
	return map(int, I().split())

def get_list():
	return list(map(int, I().split()))

def I():
	return sys.stdin.readline().strip()
for t in range(int(I())):
	n = int(I())
	L = get_list()
	D = defaultdict(lambda : 0)
	for i in L:
		D[i] += 1
	for i in D:
		print(i, end=' ')
	print()


t = int(input())
while t:
	t -= 1
	n = int(input())
	lis = list(map(int, input().split()))
	l = [0] * (2 * n + 1)
	(s1, s2) = ([], [])
	for i in range(2 * n):
		if l[lis[i]] == 0:
			s1.append(lis[i])
		l[lis[i]] += 1
	print(*s1)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	visited = [False] * (n + 1)
	ans = []
	for v in a:
		if visited[v] == False:
			ans.append(v)
			visited[v] = True
	print(*ans)
	return

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


n = int(input())
for i in range(n):
	m = int(input())
	l = []
	a = [int(i) for i in input().split()]
	for j in range(0, len(a)):
		if a[j] not in l:
			l.append(a[j])
	print(*l)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for ii in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	for i in range(2 * n):
		if arr[i] not in ans:
			ans.append(arr[i])
	print(*ans)


from sys import stdin, stdout

def input():
	return stdin.readline().strip()

def solve():
	n = int(input())
	arr = list(map(str, input().split()))
	a = []
	for i in arr:
		if i not in a:
			a.append(i)
	print(' '.join(a))
t = int(input())
for _ in range(t):
	solve()


import collections

def main():
	t = int(input())
	for cs in range(t):
		n = int(input())
		ar = list(map(int, input().split(' ')))
		print(' '.join(solve(ar, n)))

def solve(ar: list, n: int) -> list:
	ans = []
	di = collections.defaultdict(int)
	for x in ar:
		if di[x] == 0:
			ans.append(str(x))
		di[x] += 1
	return ans
main()


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(len(a)):
		if a[i] not in b:
			b.append(a[i])
	print(*b)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	pm = []
	for (i, val) in enumerate(arr):
		if d.get(val, None) is None:
			d[val] = i
		else:
			d.pop(val)
			pm.append(val)
	print(' '.join(list(map(str, pm))))


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	seq = list(map(int, input().split()))
	count = dict()
	c = 0
	for num in seq:
		if count.get(num, 0):
			continue
		else:
			count[num] = (c, num)
			c += 1
	for n in sorted(count.values()):
		print(n[1], end=' ')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	for i in l:
		if i not in p:
			p.append(i)
		if len(p) == n:
			break
	print(*p)


t = int(input())
cnt = 0
while cnt < t:
	cnt += 1
	n = int(input())
	set1 = set()
	for i in input().split():
		if int(i) in set1:
			continue
		else:
			set1.add(int(i))
			print(i, end=' ')


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	_set = set()
	ans = []
	for val in arr:
		if val in _set:
			pass
		else:
			ans.append(val)
			_set.add(val)
	print(*ans, sep=' ')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
N = inp()

def test_case(n, lnp_list):
	test_arr = []
	ret_val = ''
	for el in lnp_list:
		if el not in test_arr:
			test_arr.append(el)
			ret_val += f'{el} '
	print(ret_val.strip())
input_arr = []
for _ in range(N):
	n = inp()
	lnp_list = invr()
	input_arr.append((n, lnp_list))
for (n, lnp_list) in input_arr:
	test_case(n, lnp_list)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = [0] * (n + 1)
	b = []
	for i in range(len(a)):
		if p[a[i]] == 0:
			b.append(a[i])
			p[a[i]] = 1
	print(*b)


n = int(input())
while n:
	n = n - 1
	l = int(input())
	s = list(map(int, input().split()))
	res = [i for (n, i) in enumerate(s) if i not in s[:n]]
	for i in res:
		print(i, end=' ')


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	over = set()
	for i in a:
		if i not in over:
			print(i, end=' ')
		over.add(i)
	print()


for t in range(int(input())):
	n = int(input())
	aa = [int(s) for s in input().split(' ')]
	used = set()
	res = []
	for a in aa:
		if a not in used:
			res += [a]
			used.add(a)
	print(' '.join((str(v) for v in res)))


for _ in range(int(input())):
	n = int(input())
	arr = input().split()
	a = []
	for i in arr:
		if i not in a:
			a.append(i)
	print(' '.join(a))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	merged = [int(x) for x in input().split()]
	perm = []
	new_els = set()
	for x in merged:
		if x not in new_els:
			perm.append(str(x))
			new_els.add(x)
	print(' '.join(perm))


t = int(input())
n_list = [0 for i in range(t)]
seq_list = [[] for i in range(t)]
for i in range(t):
	n_list[i] = int(input())
	seq_list[i] = input()
	seq_list[i] = seq_list[i].split()
	for j in range(len(seq_list[i])):
		seq_list[i][j] = int(seq_list[i][j])
output_list = [[] for i in range(t)]
for i in range(t):
	n = n_list[i]
	output_list[i] = [0 for k in range(n)]
	output_list[i][0] = seq_list[i][0]
	c = 1
	for j in range(1, len(seq_list[i])):
		if seq_list[i][j] not in output_list[i]:
			output_list[i][c] = seq_list[i][j]
			c += 1
for i in range(t):
	for j in range(len(output_list[i])):
		print(output_list[i][j], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = []
	s = ''
	for i in a:
		if i not in d:
			d.append(i)
			s = s + str(i)
			s = s + ' '
	print(s)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set()
	toprint = list()
	for i in range(2 * n):
		if len(s) == n:
			break
		if l[i] not in s:
			s.add(l[i])
			print(l[i], end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	thislist = list(map(int, input().split()))
	check = [False] * n
	for i in thislist:
		if check[i - 1] == False:
			print(i, end=' ')
			check[i - 1] = True
	print()
	t = t - 1


t = int(input())
j = []
r = []
a = []
o = []
i = 0
while i < t:
	n = int(input())
	x = list(map(int, input().split()))
	k = set(x)
	for v in k:
		r.append(v)
	for u in r:
		y = x.index(u)
		a.append(y)
		c = sorted(a)
	del a[0:n]
	for z in c:
		p = x[z]
		o.append(p)
	del r[0:n]
	i = i + 1
	print(' '.join((str(f) for f in o)))
	del o[0:n]


t = int(input())
for i in range(t):
	n = int(input())
	L1 = []
	L1 = input().split()
	for j in range(len(L1)):
		L1[j] = int(L1[j])
	L2 = []
	for j in range(2 * n):
		if L1[j] not in L2:
			L2.append(L1[j])
	for j in range(n):
		print(L2[j], end=' ')


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		permutation2 = list(map(int, input().split()))
		permutation = []
		for e in permutation2:
			if e in permutation:
				continue
			else:
				permutation.append(e)
		print(str(permutation).strip('[]').replace(',', ''))
main()


inputs_cnt = int(input())
for index in range(inputs_cnt):
	reshuffle_length = int(input())
	merged_reshuffle = input().split()
	reshuffle = []
	used_items = set()
	for item in merged_reshuffle:
		if item not in used_items:
			used_items.add(item)
			reshuffle.append(item)
	print(' '.join(reshuffle))


from sys import stdin
input = stdin.readline
INF = 10 ** 9 + 7
MAX = 10 ** 7 + 7
MOD = 10 ** 9 + 7
for Ti in range(int(input().strip())):
	n = int(input().strip())
	a = [int(x) for x in input().strip().split()]
	d = {}
	ans = []
	for ai in a:
		if ai in d:
			continue
		d[ai] = 1
		ans.append(ai)
	print(*ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for j in a:
		if j not in p:
			p.append(j)
		else:
			continue
	for k in p:
		print(k, end=' ')
	print('')


def solve(size, perm):
	seen = set()
	res = [None] * size
	wi = 0
	i = 0
	while i < len(perm):
		if perm[i] in seen:
			i += 1
			continue
		seen.add(perm[i])
		res[wi] = str(perm[i])
		wi += 1
		i += 1
		if len(seen) == size:
			break
	sres = ' '.join(res)
	print(sres)

def main():
	n = int(input())
	for _ in range(n):
		size = int(input())
		perm = list(map(int, input().split()))
		solve(size, perm)
main()


def solve(a, n):
	d1 = {}
	d2 = {}
	for i in a:
		if d1.get(i) == None:
			d1[i] = 1
		else:
			d2[i] = 1
	arr = []
	for i in d1.keys():
		arr.append(i)
	return arr
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	arr = solve(a, n)
	print(*arr)


t = int(input())
for _ in range(t):
	n = int(input())
	ar = input().split()
	li = []
	for i in ar:
		if i not in li:
			li.append(i)
	st = ' '.join(li)
	print(st)


t = int(input())
for i in range(t):
	n = int(input())
	a = input().split()
	flag = []
	for j in range(2 * n):
		if a[j] not in flag:
			print(a[j], end=' ')
			flag.append(a[j])


t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	seq = [int(x) for x in input().strip().split()]
	for no in seq:
		if str(no) not in ans:
			ans += [str(no)]
	print(' '.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	lst1 = list(map(int, input().split()))
	dict1 = {}
	lst2 = []
	for i in range(len(lst1)):
		if lst1[i] not in dict1:
			dict1[lst1[i]] = 1
			lst2.append(lst1[i])
	for i in range(len(lst2)):
		print(lst2[i], end=' ')
	print()


t = int(input(''))
for i in range(0, t):
	n = int(input(''))
	l = list(map(int, input('').strip().split()))
	p = []
	k = ''
	for j in range(0, 2 * n):
		if l[j] not in p:
			p.append(l[j])
	for g in range(0, n):
		k = k + str(p[g]) + ' '
	print(k)


n = int(input())
for _ in range(n):
	m = int(input())
	ar = list(map(int, input().split()))
	x = []
	for i in ar:
		if i not in x:
			x.append(i)
	p = len(x)
	for i in range(p):
		print(x[i], end=' ')


for tc in range(int(input())):
	n = int(input())
	A = input().split(' ')
	for i in range(2 * n):
		A[i] = int(A[i])
	ind = [0] * n
	ans = []
	count = 0
	index = 0
	while count != n:
		if ind[A[index] - 1] == 0:
			ind[A[index] - 1] = 1
			ans.append(A[index])
			count += 1
		index += 1
	for i in ans:
		print(i, end=' ')
	print()


N = int(input())
for i in range(N):
	k = int(input())
	a = [True] * k
	dp = list(map(int, input().split()))
	for elem in dp:
		if a[elem - 1]:
			print(elem, end=' ')
			a[elem - 1] = False
	print('\n')


production = True
import sys, math, collections

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for i in range(multi)]
	else:
		next_line = sys.stdin.readline()[:-1]
		if input_format >= 10:
			use_list = False
			input_format = int(str(input_format)[-1])
		else:
			use_list = True
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = list(next_line)
		elif input_format == 4:
			formatted_input = list(map(int, list(next_line)))
		elif input_format == 5:
			formatted_input = next_line.split()
		else:
			formatted_input = [next_line]
		return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format=0, newline=True):
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 2:
		formatted_output = '\n'.join(map(str, output_line))
	print(formatted_output, end='\n' if newline else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)

def mapl(iterable, format=0):
	if format == 0:
		return list(map(int, iterable))
	elif format == 1:
		return list(map(str, iterable))
	elif format == 2:
		return list(map(list, iterable))

def solve():
	n = input(11)
	a = input(1)
	b = set()
	y = []
	for i in a:
		if i not in b:
			y.append(i)
			b.add(i)
	out(y, 1)
	return
for i in range(input(11)):
	solve()


t = int(input())
from sys import *

def f(arr, k, x):
	count = 0
	for il in arr:
		count += il // x
	if count >= k:
		return True
	else:
		return False
for ip in range(t):
	n = int(input())
	arr = list(map(int, stdin.readline().split()))
	qr = []
	se = set()
	for ip in range(2 * n):
		if arr[ip] not in se:
			qr.append(str(arr[ip]))
			se.add(arr[ip])
	print(' '.join(qr))


t = int(input())
for lp in range(t):
	num = int(input())
	a = list(map(int, input().split()))
	c = []
	for i in a:
		if i not in c:
			print(i, end=' ')
			c.append(i)
	print()


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	d = dict()
	for i in range(1, n + 1):
		d[i] = 0
	for i in range(2 * n):
		if d[arr[i]] == 0:
			print(arr[i], end=' ')
			d[arr[i]] = d[arr[i]] + 1
	print(' ')


from math import *
from collections import *
from bisect import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	v = set()
	r = []
	for i in a:
		if i in v:
			continue
		v.add(i)
		r.append(i)
	print(*r)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	ans = []
	for j in l:
		if j not in d.keys():
			d[j] = 1
			ans.append(j)
	print(*ans)


t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = [0] * (2 * n)
	for i in range(n):
		ind = a.index(i + 1)
		ans[ind] = i + 1
	anss = []
	for i in ans:
		if i != 0:
			print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	u = set()
	res = []
	for num in arr:
		if num not in u:
			res.append(str(num))
			u.add(num)
	print(' '.join(res))


import sys
t = int(sys.stdin.readline().rstrip())
ar_len = list()
ar = list()
for i in range(t):
	ar_len.append(int(sys.stdin.readline().rstrip()))
	ar.append(list(map(int, sys.stdin.readline().rstrip().split())))
for i in range(t):
	now = ar[i]
	now_len = ar_len[i]
	now_ans = list()
	for j in range(len(now)):
		if len(now_ans) == now_len:
			break
		elif now[j] not in now_ans:
			now_ans.append(now[j])
	for j in range(now_len):
		print(now_ans[j], end=' ')
	if i != t - 1:
		print()


for _ in range(int(input())):
	n = int(input())
	seen = set()
	for x in map(int, input().split()):
		if x not in seen:
			print(x, end=' ')
		seen.add(x)
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	num = []
	for i in range(2 * n):
		if l[i] not in num:
			num.append(l[i])
	print(*num)


from collections import Counter
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	a = Counter(arr)
	print(*a.keys(), sep=' ')


t = int(input())
for i in range(t):
	input()
	result = []
	a = [int(i) for i in input().split()]
	for k in a:
		if k not in result:
			result.append(k)
	print(*result)


def solve():
	t = int(input())
	while t > 0:
		n = int(input())
		cnt = [0 for _ in range(n + 1)]
		a = list(map(int, input().split()))
		p = list()
		for i in range(2 * n):
			num = a[i]
			if cnt[num] == 0:
				p.append(num)
			cnt[num] += 1
		print(' '.join((str(num) for num in p)))
		t -= 1
solve()


import math
from sys import stdin
from collections import Counter, defaultdict, deque
input = stdin.readline
mod = pow(10, 9) + 7

def solve():
	n = int(input())
	l1 = list(map(int, input().split()))
	c = 0
	d = defaultdict(int)
	for i in l1:
		d[i] += 1
	l2 = []
	for i in range(2 * n):
		if d[l1[i]] == 2:
			l2.append(l1[i])
			d[l1[i]] -= 1
	print(*l2)
for _ in range(int(input())):
	solve()


from queue import LifoQueue

def print_sol(c, sol):
	print('Case #{}: {}'.format(c, sol))

def rd_int():
	return int(input())

def rd_str():
	return input()

def rd_str_lst():
	return input().split(' ')

def sp_str_lst():
	return list(input())

def rd_int_lst():
	return [int(i) for i in rd_str_lst()]

def sp_int_lst():
	return [int(i) for i in sp_str_lst()]

def dfs(g, i, v):
	v[i] = True
	for j in g[i]:
		if not v[j]:
			dfs(g, j, v)
	print(i)

def dfs_iter(g, i, n):
	v = [False] * n
	stack = LifoQueue()
	stack.put(i)
	while stack.not_empty:
		u = stack.get()
		v[u] = True
		print(u)
		for i in g[u]:
			if not v[i]:
				stack.put(i)

def main():
	t = rd_int()
	for c in range(1, t + 1):
		n = rd_int()
		a = rd_int_lst()
		s = [False] * n
		sol = [0] * n
		cn = 0
		i = 0
		while cn < n and i < 2 * n:
			if not s[a[i] - 1]:
				s[a[i] - 1] = True
				sol[cn] = a[i]
				cn += 1
			i += 1
		print(*sol)
main()


t = int(input())
f = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))[:2 * n]
	a = list(dict.fromkeys(a))
	listToStr = ' '.join([str(elem) for elem in a])
	print(listToStr)


for z in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	Set = []
	for i in range(2 * n):
		if a[i] not in Set:
			Set.append(a[i])
	for x in Set:
		print(x, end=' ')
	print()


t = int(input())
for _ in range(t):
	l1 = input()
	A = list(map(int, input().split()))
	lt = []
	for i in A:
		if i not in lt:
			lt.append(i)
	print(*lt)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = sorted(set(a), key=lambda x: a.index(x))
	print(*b)


def print_perm(inp):
	arr = list(map(int, inp.split()))
	arr2 = []
	for elem in arr:
		if elem not in arr2:
			arr2.append(elem)
	print(*arr2, sep=' ')
n = int(input())
for i in range(n):
	_ = input()
	inp = input()
	print_perm(inp)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	t = []
	ans = []
	for i in l:
		if i not in t and i > 0:
			ans.append(i)
			t.append(i)
	for i in ans:
		print(i, end=' ')
	print()


def fcnt1():
	result = ''
	for _ in range(int(input())):
		input()
		a = list(map(int, input().split()))
		b = set()
		for i in a:
			if i not in b:
				b.add(i)
				result += f'{i} '
		result += '\n'
	print(result[:-1])
fcnt1()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(lambda x: int(x) - 1, input().split()))
	f = [False] * n
	p = []
	c = 0
	for i in range(2 * n):
		if f[arr[i]]:
			continue
		f[arr[i]] = True
		c += 1
		p.append(arr[i] + 1)
		if c == n:
			break
	print(*p)


def main():
	for __ in [0] * int(input()):
		N = int(input())
		(*A,) = map(int, input().split())
		c = [0] * (N + 1)
		for a in A:
			if c[a]:
				continue
			print(a, end=' ')
			c[a] = 1
		print()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().rstrip().split()))
	ans = []
	for item in l:
		if item in ans:
			pass
		else:
			ans.append(item)
	for i in range(len(ans) - 1):
		print('{} '.format(ans[i]), end='')
	print('{}'.format(ans[-1]), end='')
	print('')


for _ in ' ' * int(input()):
	a = int(input())
	b = list(map(int, input().split()))
	z = []
	for i in b:
		if i not in z:
			z += [i]
	print(*z)


t = int(input())
for case in range(t):
	n = int(input())
	t = input().split()
	vu = set()
	rep = []
	for i in range(2 * n):
		if t[i] not in vu:
			rep.append(t[i])
			vu.add(t[i])
	print(' '.join(rep))


t = int(input())
for x in range(0, t):
	m = int(input())
	l = list(map(int, input().strip().split()))[:2 * m]
	l2 = []
	l3 = []
	y = max(l)
	for i in range(0, y + 1):
		l2.append(0)
	for i in range(0, 2 * m):
		if l2[l[i]] == 0:
			l3.append(l[i])
		l2[l[i]] += 1
	print(*l3, sep=' ')


t = int(input())
lst = []
for i in range(t):
	n = int(input())
	lst.clear()
	a = list(map(int, input().split()))
	for j in range(len(a)):
		if a[j] not in lst:
			lst.append(a[j])
	print(*lst)


t = int(input())
for _ in range(t):
	mapper = [0] * 51
	n = int(input())
	arr = map(int, input().split())
	ans = []
	for v in arr:
		if mapper[v] == 0:
			mapper[v] = 1
			ans.append(v)
	print(*ans, sep=' ')


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return list(map(int, input().split()))

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for i in range(INT()):
	n = INT()
	arr = LIST()
	d = {}
	for i in arr:
		if i in d:
			continue
		else:
			d[i] = 1
	ans = []
	for i in d:
		ans.append(i)
	print(*ans)


t = int(input())
while t > 0:
	k = int(input())
	num = list(map(int, input().split(' ')))
	visited = []
	for i in range(len(num)):
		if num[i] in visited:
			continue
		visited.append(num[i])
	for i in range(len(visited)):
		print(visited[i], end=' ')
	t -= 1


for teat in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	lt = []
	for x in p:
		if x not in lt:
			lt.append(x)
	print(*lt)


from sys import stdin, stdout
for query in range(int(stdin.readline())):
	n = int(stdin.readline())
	c = [int(x) for x in stdin.readline().split()]
	a = [c[0]]
	la = 1
	lb = 0
	for x in range(1, 2 * n):
		if la != lb and c[x] == a[lb]:
			lb += 1
		else:
			a.append(c[x])
			la += 1
	for x in a:
		stdout.write(str(x) + ' ')
	stdout.write('\n')


import sys
import math, bisect
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	N = int(input())
	A = Neo()
	Ans = []
	for i in A:
		if i not in Ans:
			Ans.append(i)
	print(*Ans)


for k in range(int(input())):
	a = int(input())
	lii = list(map(int, input().split()))
	x = []
	for i in lii:
		if i not in x:
			x.append(i)
			print(i, end=' ')
	print()


def read():
	return list(map(int, input().split()))

def solve():
	n = int(input())
	arr = read()
	s = set()
	p = [arr[0]]
	s.add(p[0])
	for i in range(1, 2 * n):
		if arr[i] not in s:
			p.append(arr[i])
		s.add(arr[i])
	print(*p)
	return
t = int(input())
for i in range(1, t + 1):
	solve()


from collections import Counter
from math import ceil, gcd, log, log2
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	d = {i: True for i in range(1, n + 1)}
	ans = []
	for i in arr:
		if d[i]:
			ans.append(i)
			d[i] = False
		else:
			continue
	print(' '.join((str(i) for i in ans)))


from sys import stdin, stdout
import math
from collections import Counter, deque
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
IN = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()
mod = 1000000007

def s(a):
	print(' '.join(list(map(str, a))))

def solve():
	n = I()
	a = L()
	b = []
	for i in a:
		if i not in b:
			b += [i]
	s(b)
for _ in range(I()):
	solve()


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		n = I()
		arr = L()
		lis = []
		for i in range(2 * n):
			if arr[i] not in lis:
				lis.append(arr[i])
		print(*lis)
main()


for _ in range(int(input())):
	n = int(input())
	a = [False for _ in range(n)]
	for x in input().split():
		p = int(x)
		if a[p - 1] == False:
			print(p, end=' ')
			a[p - 1] = True
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	i = 0
	j = 0
	while i < 2 * n:
		if arr[i] != -1:
			ans.append(arr[i])
			j = i + 1
			while j < 2 * n:
				if arr[j] == arr[i]:
					arr[j] = -1
					break
				j += 1
		i += 1
	ans = list(map(str, ans))
	s = ' '.join(ans)
	print(s)


T = int(input())
for _ in range(T):
	n = int(input())
	arr = [int(i) for i in input().split(' ')]
	(a, b) = ([], [])
	for el in arr:
		if el in a:
			b.append(el)
		elif el in b:
			a.append(el)
		else:
			a.append(el)
	print(' '.join([str(i) for i in a]))


for _ in range(int(input())):
	(n, l) = (int(input()), dict.fromkeys(map(int, input().split())))
	print(*l)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(lambda x: int(x), input().split(' ')))
	retval = ''
	indices = []
	for i in range(1, n + 1):
		indices.append((arr.index(i), i))
	indices.sort()
	for i in range(n):
		retval = retval + str(indices[i][1])
		retval = retval + ' '
	print(retval)


N_SETS = int(input())
for i in range(N_SETS):
	_ = int(input())
	p = [int(x) for x in input().split()]
	r = []
	for x in p:
		if x not in r:
			r.append(x)
	for x in r:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	used = set()
	res = []
	for c in a:
		if c not in used:
			used.add(c)
			res.append(c)
	print(*res)


t = int(input())
while t != 0:
	n = int(input())
	list1 = input().split()
	for i in range(2 * n):
		if list1[i] in list1[i + 1:2 * n]:
			print(list1[i], end=' ')
	print('')
	t -= 1


def solve(n, l):
	res = []
	for i in range(2 * n):
		if l[i] not in res:
			res.append(l[i])
	print(' '.join((str(x) for x in res)))
t = int(input())
for i in range(t):
	n = int(input())
	solve(n, [int(x) for x in input().split()])


t = int(input())
lst = []
for _ in range(t):
	g = int(input())
	l = input().split()
	a = []
	for x in l:
		if not x in a:
			a.append(x)
	lst.append(a)
for x in lst:
	print(*x)


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in range(1, n + 1):
		d[i] = 0
	p = []
	for i in range(2 * n):
		if d[l[i]] == 0:
			d[l[i]] = 1
			p.append(l[i])
	print(*p)
	t -= 1


import sys
import math
from collections import defaultdict
fi = sys.stdin.readline
fii = lambda : int(fi())
fis = lambda : fi()
fil = lambda : [int(x) for x in fi().split(' ')]
fif = lambda : float(fi())

def solve():
	n = fi()
	arr = fil()
	d = defaultdict(bool)
	res = []
	for i in range(len(arr)):
		if not d[arr[i]]:
			res.append(arr[i])
			d[arr[i]] = True
	print(' '.join([str(x) for x in res]))
t = fii()
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = []
	for i in range(2 * n):
		if a[i] in s:
			continue
		else:
			s.append(a[i])
	print(*s)


q = int(input())
for blah in range(q):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	mem = set()
	for i in range(2 * n):
		if arr[i] in mem:
			pass
		else:
			print(arr[i], end=' ')
			mem.add(arr[i])
	print()


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	b = []
	for i in arr:
		if i not in b:
			b.append(i)
	for i in b:
		print(i, end=' ')
	print('\n')


for x in range(int(input())):
	l = int(input())
	lst = list(map(int, input().split()))
	f = list()
	for k in lst:
		if k not in f:
			f.append(k)
	print(*f)


inp = int(input())
for i in range(inp):
	leng = int(input())
	seq = input().split(' ')
	arr = []
	dic = {}
	for j in seq:
		if j not in dic:
			dic[j] = True
		else:
			arr.append(j)
	print(' '.join(arr))


import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def check_sorted(a):
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			return False
	return True

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def main():
	for i in range(ii()):
		n = ii()
		l = li()
		x = []
		for i in l:
			if i not in x:
				x.append(i)
				print(i, end=' ')
		print()
main()


n = int(input())
for i in range(n):
	x = int(input())
	arr = [int(i) for i in input().split()]
	ans = []
	st = set()
	for i in arr:
		if i not in st:
			ans.append(i)
			st.add(i)
	print(' '.join([str(i) for i in ans]))


t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	ar = list(map(int, input().split()))
	for i in range(len(ar)):
		if ar[i] not in ans:
			ans.append(ar[i])
		if len(ans) == n:
			break
	for i in ans:
		print(i, end=' ')


def calc(num_list: list):
	new_list = list()
	for i in num_list:
		if i not in new_list:
			new_list.append(i)
	for ele in new_list:
		print(ele, end=' ')
	print()
t = int(input())
total_list = list(list())
for _ in range(t):
	n = int(input())
	numList = list(map(int, input().split()))
	total_list.append(numList)
for elem in total_list:
	calc(elem)


rr = lambda : input().strip()
rri = lambda : int(rr())
rrm = lambda : [int(x) for x in rr().split()]
from sys import stdin, stdout, setrecursionlimit

def sol():
	n = rri()
	vis = [0 for i in range(n + 1)]
	lis = rrm()
	res = []
	for i in lis:
		if vis[i] == 0:
			res.append(i)
			vis[i] = 1
	print(*res)
	return

def main():
	T = rri()
	for t in range(1, T + 1):
		ans = sol()
main()


for i in range(int(input())):
	t = input()
	A = list((int(_) for _ in input().split()))
	print(*dict.fromkeys(A))


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ar1 = []
	for i in ar:
		if i not in ar1:
			ar1.append(i)
		if len(ar1) == n:
			break
	print(*ar1)


for i in range(int(input())):
	n = int(input())
	ans = list()
	l = list(map(int, input().split()))
	for j in l:
		if j in ans:
			continue
		else:
			ans.append(j)
	print(*ans)


n = int(input())
for i in range(n):
	m = int(input())
	d = []
	c = list(map(int, input().split(' ')))
	d.append(c[0])
	for j in range(len(c)):
		if c[j] in d:
			continue
		else:
			d.append(c[j])
	for i in d:
		print(i, end=' ')
	print()


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	l = []
	for i in arr:
		if i in l:
			continue
		else:
			l.append(i)
			print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	nums = map(int, input().split())
	aSet = set()
	result = []
	for num in nums:
		if num not in aSet:
			aSet.add(num)
			result.append(num)
			if len(result) == n:
				break
	print(' '.join(map(str, result)))


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for el in a:
		if el not in b:
			b.append(el)
	for el in b:
		print(el, end=' ')
	print()


t = int(input())
for v in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	dic = {}
	an = []
	for i in range(n + n):
		ans = dic.get(li[i], -1)
		if ans == -1:
			an.append(li[i])
			dic.update({li[i]: 1})
	for i in range(n):
		print(an[i], end=' ')
	print()


t = int(input())
while t:
	t = t - 1
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	ans = []
	for w in l:
		if w not in d:
			d[w] = 1
			ans.append(w)
	for w in ans:
		print(w, end=' ')
	print()


import sys
inputlist = sys.stdin.readlines()
number_of_testcases = int(inputlist[0].strip())
for i in range(number_of_testcases):
	n = int(inputlist[2 * i + 1].strip())
	numbers_list = list(map(int, inputlist[2 * i + 2].strip().split(' ')))
	main_list = []
	for i in numbers_list:
		if i not in main_list:
			main_list.append(i)
	print(' '.join(map(str, main_list)))


t = int(input())
for i in range(t):
	n = int(input())
	P = list(map(int, input().split()))
	A = []
	for i in range(2 * n):
		if P[i] in set(A):
			continue
		else:
			A.append(P[i])
	A = [str(a) for a in A]
	A = ' '.join(A)
	print(A)


T = int(input())
for _ in range(T):
	N = int(input())
	arr = [int(i) for i in input().split()]
	res = []
	for x in arr:
		if x not in res:
			res.append(x)
	for x in res:
		print(x, end=' ')
	print()


t = int(input())
while t:
	t -= 1
	x = int(input())
	a = [int(i) for i in input().split()]
	d = []
	for i in a:
		if i not in d:
			d.append(i)
		if len(d) == x:
			break
	for i in d:
		print(i, end=' ')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	done = [False] * (n + 1)
	ans = []
	for i in l:
		if done[i]:
			continue
		ans.append(i)
		done[i] = True
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p1 = []
	p2 = []
	for i in a:
		c1 = p1.count(i)
		c2 = p2.count(i)
		if c1 == c2:
			p1.append(i)
		else:
			p2.append(i)
	print(*p1)


t = int(input())
for T in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	s = set()
	ans = []
	for i in l:
		if i not in s:
			s.add(i)
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	myList = list(dict.fromkeys(lst))
	print(*myList)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	an = [l[0]]
	vis = [0] * (n + 1)
	vis[l[0]] = 1
	for i in range(1, 2 * n):
		if an[-1] != l[i] and vis[l[i]] == 0:
			an.append(l[i])
			vis[l[i]] = 1
	print(*an)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	r = {}
	for i in s:
		if r.get(i, 0) == 0:
			print(i, end=' ')
			r[i] = 1
	print('')


t = int(input())
for x in range(t):
	novalista = []
	n = int(input())
	lista = [int(i) for i in input().split()]
	for y in range(len(lista)):
		if lista[y] not in novalista:
			novalista.append(lista[y])
	print(*novalista, sep=' ')


from collections import Counter
for i in range(int(input())):
	m = int(input())
	n = Counter(list(input().split()))
	for j in n.keys():
		print(j, end=' ')
	print('')


for i in range(int(input())):
	s = set()
	n = int(input())
	a = list(map(int, input().split()))
	r = []
	for i in range(2 * n):
		if a[i] not in s:
			s.add(a[i])
			r.append(a[i])
	print(*r)


t = int(input())
for i in range(t):
	l = int(input())
	p = list(map(int, input().split()))
	r = list()
	j = 0
	for e in p:
		if e not in r:
			r.append(e)
			j += 1
			print(e, end=' ')
		if j == l:
			break


for i in range(int(input())):
	m = int(input())
	l = list(map(str, input().split()))
	p = []
	for chr in l:
		if chr not in p:
			p.append(chr)
	print(' '.join(p))


def solver():
	n = int(input())
	arr = list(map(int, input().split()))
	arr = list(dict.fromkeys(arr))
	print(*arr)
for _ in range(int(input())):
	solver()


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	ai = list(map(int, input().split()))
	ci = []
	defa = defaultdict(int)
	for i in ai:
		if i not in ci:
			ci.append(i)
	print(*ci)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	hak = {}
	out = []
	for i in s:
		if i not in hak:
			out.append(i)
		hak[i] = 0
	for i in out:
		print(i, end=' ')
	print()


import math
from collections import deque
from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	was = set()
	for i in arr:
		if i in was:
			continue
		res.append(i)
		was.add(i)
	print(*res)


from collections import Counter
t = int(input())
for _ in range(t):
	N = int(input())
	L = list(map(int, input().split()))
	count = Counter(L)
	for k in count.keys():
		print(k, end=' ')
	print()


from collections import Counter
for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = Counter(b)
	for j in c.keys():
		print(j, end=' ')
	print('')


def solve(n, nums):
	hash = [False] * (n + 1)
	ans = []
	for num in nums:
		if not hash[num]:
			ans.append(str(num))
			hash[num] = True
	return ' '.join(ans)
t = int(input())
while t:
	n = int(input())
	nums = list(map(int, input().split()))
	print(solve(n, nums))
	t -= 1


def uniq(input):
	output = []
	for x in input:
		if x not in output:
			output.append(x)
	return output

def sequence():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		s = uniq(a)
		print(' '.join(map(str, s)))
sequence()


def lol(f):
	for i in f:
		print(i, end=' ')
	print()

def main():
	for i in range(int(input())):
		d = int(input())
		f = list(map(int, input().split()))
		f = list(dict.fromkeys(f))
		lol(f)
main()


import sys
inp = [int(x) for x in sys.stdin.read().split()]
ii = 0
t = inp[0]
ii += 1
for _ in range(t):
	n = inp[ii]
	ii += 1
	a = inp[ii:ii + 2 * n]
	ii += 2 * n
	perm = []
	for x in a:
		if x not in perm:
			perm.append(x)
	print(*perm)


def main():
	t = int(input())
	while t > 0:
		n = int(input())
		li = list(map(int, input().split()))
		li = set(li)
		for i in li:
			print(i, end=' ')
		t -= 1
main()


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	dct = dict()
	for i in range(2 * n):
		index = dct.get(lst[i], 0)
		if index == 0:
			dct[lst[i]] = i + 1
	for i in dct.keys():
		print(i, end=' ')
	print()


n = int(input())
b = []
for i in range(n):
	x = int(input())
	a = [int(i) for i in input().split()]
	d = {}
	for j in range(len(a)):
		if a[j] in d:
			d[a[j]] += 1
		else:
			d[a[j]] = 1
	b.append(list(d.keys()))
for i in range(len(b)):
	for j in range(len(b[i])):
		print(b[i][j], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	found = set()
	for i in l:
		if i not in found:
			found.add(i)
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	ans = [0] * n
	L = []
	for num in arr:
		if ans[num - 1]:
			continue
		ans[num - 1] = 1
		L.append(str(num))
	print(' '.join(L))


for _ in range(int(input())):
	n = int(input())
	d = [False] * (n + 1)
	l = list(map(int, input().split()))
	for i in l:
		if not d[i]:
			d[i] = True
			print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	l = list()
	for i in a:
		if i not in l:
			l.append(i)
		else:
			continue
	s = ''
	for i in l:
		s += str(i) + ' '
	print(s)


from collections import OrderedDict
t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	p = list(OrderedDict.fromkeys(p))
	print(*p, sep=' ')


tc = int(input())
for i in range(tc):
	x = int(input())
	y = list(map(int, input().split()))
	z = []
	str1 = ''
	for i in y:
		if i not in z:
			z.append(i)
	for i in z:
		str1 += str(i) + ' '
	print(str1)


def solve(n, a):
	p = []
	for x in a:
		if x not in p:
			p.append(x)
	return p
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	sol = solve(n, a)
	print(' '.join(map(str, sol)))


for _ in range(int(input())):
	n = int(input())
	p_s = list(map(int, input().split()))
	ans = []
	for p in p_s:
		if p not in ans:
			ans.append(p)
	ans = ' '.join(map(str, ans))
	print(ans)


n = int(input())
for i in range(n):
	k = int(input())
	a = map(int, input().split(' '))
	yes = [False] * k
	res = [0] * k
	cur = 0
	for el in a:
		if not yes[el - 1]:
			yes[el - 1] = True
			res[cur] = str(el)
			cur += 1
	print(' '.join(res))


from sys import stdin, stdout

def solve():
	n = int(input())
	arr = input().split()
	a = []
	for i in arr:
		if i not in a:
			a.append(i)
	print(' '.join(a))
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(obj) for obj in input().split()]
	p = [False] * (n + 1)
	ans = []
	for x in a:
		if not p[x]:
			p[x] = True
			ans.append(x)
	print(*ans)


s = int(input())
for i in range(s):
	p = int(input())
	q = list(map(int, input().split()))
	l = list(dict.fromkeys(q))
	for j in l:
		if j in q:
			print(j, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	data = list(map(int, input().split()))
	nl = []
	for j in data:
		if j not in nl:
			nl.append(j)
	print(*nl)


import sys
input = sys.stdin.readline
t = int(input())
for t1 in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	s = ''
	d = {}
	for i in range(2 * n):
		if d.get(l[i], 0) == 0:
			s += str(l[i]) + ' '
			d[l[i]] = 1
	print(s)


test = int(input())
for i in range(test):
	n = int(input())
	arr = [int(i) for i in input().split()]
	visited = [0 for i in range(n + 1)]
	ans = []
	for i in range(len(arr)):
		if visited[arr[i]] == 0:
			ans.append(arr[i])
			visited[arr[i]] = 1
	print(*ans)


try:
	from collections import Counter
	t = int(input())
	while t:
		n = int(input())
		l = list(map(int, input().split()))
		a = []
		p = Counter(l)
		for i in range(len(l)):
			m = l[i]
			if p[m] != 0:
				a.append(l[i])
				p[m] = 0
		print(*a)
except:
	pass


for i in range(int(input())):
	x = int(input())
	lst = list(map(int, input().split()))
	k = []
	for i in range(len(lst)):
		if lst[i] not in k:
			k.append(lst[i])
	print(*k)


t = int(input())
while t != 0:
	n = int(input())
	list1 = list(map(int, input().split()))
	dicto = {}
	ans = []
	for i in range(len(list1)):
		p = list1[i]
		if p in dicto.keys():
			pass
		else:
			ans.append(p)
			dicto[p] = 1
	print(*ans)
	t -= 1


from __future__ import division, print_function
import os, sys
import math
import collections
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class my_dictionary(dict):

	def __init__(self):
		self = dict()

	def add(self, key, value):
		self[key] = value

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(my_list):
	freq = {}
	for item in my_list:
		if item in freq:
			freq[item] += 1
		else:
			freq[item] = 1
	return freq

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def commonn(a, b, n):
	c = []
	for i in range(n):
		if a[i] == b[i]:
			c.append('-1')
		else:
			c.append(b[i])
	return c

def primeFactors(n):
	j = []
	while n % 2 == 0:
		j.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			j.append(int(n))
			n = n / i
	if n > 2:
		j.append(int(n))
	return j

def sumdigit(n):
	n = str(n)
	k = 0
	for i in range(len(n)):
		k += int(n[i])
	return k

def largeseq1(a, cost, ini, des):
	ind = -1
	mx = -1000000007
	j = 0
	for i in range(des - 1, ini):
		if a[i] > mx:
			mx = a[i]
			j += cost[i]
			ind = i
	if ind != ini - 1:
		return -1
	else:
		return j

def largeseq2(a, cost, ini, des):
	ind = -1
	mx = -1000000007
	j = 0
	for i in range(des - 1, ini - 2, -1):
		if a[i] > mx:
			mx = a[i]
			j += cost[i]
			ind = i
	if ind != ini - 1:
		return -1
	else:
		return j

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		b = []
		for i in a:
			if i not in b:
				b.append(i)
		print(*b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import heapq as hp
import collections
import bisect

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def range_n():
	return range(int(input()))

def getint():
	return int(input())

def main():
	for _ in range_n():
		n = getint()
		a = l_unpack()
		ans = []
		vstd = set()
		for i in a:
			if i not in vstd:
				vstd.add(i)
				ans.append(i)
		print(*ans)
main()


T = int(input())
for _ in range(T):
	n = int(input())
	li = list(map(int, input().split()))
	l = []
	for item in li:
		if item not in l:
			if len(l) < n:
				l.append(item)
	print(*l)


from collections import OrderedDict
for w in range(int(input())):
	x = input()
	n = list(map(int, input().split()))
	rep = list(OrderedDict.fromkeys(n))
	print(*rep)


import sys
t = int(input())
while t:
	n = int(input())
	s = sys.stdin.readline().split()
	ans = [i for (n, i) in enumerate(s) if i not in s[:n]]
	print(' '.join(ans))
	t -= 1


t = int(input())
while t > 0:
	n = int(input())
	arr = [int(i) for i in input().split()]
	s = set()
	l = []
	for i in arr:
		if i in s:
			continue
		else:
			l.append(i)
			s.add(i)
	print(*l)
	t -= 1


t = int(input())
for _ in range(t):
	seen = set()
	n = int(input())
	nums = input().split()
	res = []
	for n in nums:
		if n not in seen:
			res.append(n)
			seen.add(n)
	print(' '.join(res))


for _ in range(int(input())):
	n = int(input())
	r = list(map(int, input().strip().split(' ')))
	li = []
	for i in r:
		if li.count(i) == 0:
			li.append(i)
	for x in li:
		print(x, end=' ')
	print('')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	vis = [-1]
	for element in a:
		if element not in vis:
			vis.append(element)
			ans.append(element)
	for i in range(len(ans) - 1):
		print(ans[i], end=' ')
	print(ans[len(ans) - 1])


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	arr = n * [0]
	arr2 = []
	for j in l:
		if arr[j - 1] == 0:
			arr[j - 1] = 1
			arr2.append(j)
			if arr == n * [1]:
				break
	for i in arr2:
		print(i, end=' ')
	print()


import sys
infile = sys.stdin
next(infile)
for line in infile:
	n = line
	l = list(map(int, infile.readline().split()))
	res = []
	for li in l:
		if li not in res:
			res.append(li)
	print(*res)


import os, io
from sys import stdout
import collections
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def primes(n):
	sieve = [True] * n
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i]:
			sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [i for i in range(3, n, 2) if sieve[i]]

def binomial_coefficient(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def powerOfK(k, max):
	if k == 1:
		return [1]
	if k == -1:
		return [-1, 1]
	result = []
	n = 1
	while n <= max:
		result.append(n)
		n *= k
	return result

def divisors(n):
	i = 1
	result = []
	while i * i <= n:
		if n % i == 0:
			if n / i == i:
				result.append(i)
			else:
				result.append(i)
				result.append(n / i)
		i += 1
	return result

def distance(xa, ya, xb, yb):
	return ((ya - yb) ** 2 + (xa - xb) ** 2) ** 0.5

def digitsSum(n):
	if n == 0:
		return 0
	r = 0
	while n > 0:
		r += n % 10
		n //= 10
	return r

def isValid(i, j, n, m):
	return i >= 0 and i < n and (j >= 0) and (j < m)

def print_grid(grid):
	for line in grid:
		print(' '.join(map(str, line)))

def kadane(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def prefixSum(arr):
	for i in range(1, len(arr)):
		arr[i] = arr[i] + arr[i - 1]
	return arr

def ceil(n, d):
	if n % d == 0:
		return n // d
	else:
		return n // d + 1

def _abs(a, b):
	return int(abs(a - b))

def evenodd(l):
	even = [e for e in l if e & 1 == 0]
	odd = [e for e in l if e & 1]
	return (even, odd)
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = set()
	arr = []
	for e in l:
		if e in s:
			continue
		arr.append(e)
		s.add(e)
	print(' '.join(list(map(str, arr))))


for i in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	l = [m[0]]
	for j in range(1, len(m)):
		if m[j] in l:
			pass
		else:
			l.append(m[j])
	print(*l)


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = get_array()
	ans = []
	for i in a:
		if i not in ans:
			ans.append(i)
	print(*ans)


for x in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	v = [0] * n
	a = []
	for i in range(2 * n):
		if v[m[i] - 1] == 0:
			a.append(m[i])
			v[m[i] - 1] = 1
	print(*a)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	fin = []
	for i in l:
		if i not in fin:
			fin.append(i)
	for j in fin:
		print(j, end=' ')
	print()


a = int(input())
for i in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	for j in range(b - 1):
		print(c[0], end=' ')
		d = c[0]
		c.pop(0)
		c.remove(d)
	print(c[0])


count = int(input())
for i in range(count):
	n = int(input())
	v = []
	v2 = list(map(int, input().split(' ')))
	for j in range(2 * n):
		if v2[j] in v:
			k = 0
		else:
			v.append(v2[j])
		if len(v) == n:
			break
	for q in range(n):
		print(v[q], end=' ')


from collections import deque
import sys

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	n = int(inp())
	a = list(map(int, inp().split()))
	s = set()
	ans = []
	for i in a:
		if i not in s:
			s.add(i)
			ans.append(i)
	print(*ans)


t = int(input())
while t > 0:
	(n, res, i) = (int(input()), [], 0)
	list = [int(i) for i in input().split()]
	while i < 2 * n:
		(j, flag) = (0, True)
		while j < len(res):
			if res[j] == list[i]:
				flag = False
				break
			j += 1
		if flag:
			res.append(list[i])
		i += 1
	for j in range(len(res)):
		print(res[j], ' ', sep='', end='')
	print()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	h = {}
	result = []
	for i in l:
		if h.get(i, 0) == 0:
			result.append(i)
			h[i] = 1
		continue
	for i in result:
		print(i, end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	ans = []
	for i in range(2 * n):
		if arr[i] in ans:
			pass
		else:
			ans.append(arr[i])
	for i in ans:
		print(i, end=' ')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	seq = []
	for ai in a:
		if not ai in seq:
			seq.append(ai)
		if len(seq) == n:
			print(' '.join(map(str, seq)))
			break


for _ in range(int(input())):
	input()
	a = list(map(int, input().split()))
	l = []
	t = []
	for i in a:
		if i not in l:
			l.append(i)
		else:
			t.append(i)
	print(*l)


from collections import OrderedDict
for i in range(int(input())):
	n = int(input())
	t = list(map(int, input().split()))
	a = {}
	for i in t:
		if i not in a:
			a[i] = 1
	r = []
	for i in a:
		r.append(i)
	for i in r:
		print(i, end=' ')


n = int(input())
for i in range(n):
	t = int(input())
	a = list(map(int, input().split(' ')))
	b = set(a)
	b = list(b)
	c = []
	for j in range(len(a)):
		for k in range(len(b)):
			if a[j] == b[k]:
				c.append(a[j])
				b.remove(b[k])
				break
	print(*c)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	r = []
	for j in l:
		if j not in r:
			r.append(j)
	print(*r)


for u in range(int(input())):
	n = int(input())
	x = [int(w) for w in input().split()]
	l = []
	for i in range(2 * n):
		if x[i] not in l:
			l.append(x[i])
	print(*l)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	h = [0] * n
	j = 0
	for i in range(2 * n):
		if l[i] not in h:
			h[j] = l[i]
			j += 1
	for i in range(n):
		print(h[i], end=' ')
	print()


for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	ans = []
	kek = set()
	for elem in ar:
		if elem not in kek:
			kek.add(elem)
			ans.append(elem)
	print(*ans)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(str, input().split()))
	num = set()
	ans = ''
	for i in arr:
		if i not in num:
			num.add(i)
			ans += i + ' '
	print(ans)


def solve():
	N = int(input())
	arr = list(map(int, input().split()))
	first = []
	second = []
	i = 0
	for x in arr:
		if len(first) == 0:
			first.append(x)
		elif i < len(first) and first[i] == x:
			second.append(x)
			i += 1
		else:
			first.append(x)
	return first

def main():
	for _ in range(int(input())):
		for x in solve():
			print(x, end=' ')
		print()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = str(input()).split(' ')
	for k in range(2 * n):
		a[k] = int(a[k])
	l = []
	i = 0
	while a != []:
		l.append(a[0])
		a.remove(l[-1])
		a.remove(l[-1])
		i += 1
	for i in range(n):
		print(l[i], end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	vis = [False for i in range(n)]
	res = []
	for i in range(len(a)):
		if vis[a[i] - 1] == False:
			res.append(a[i])
			vis[a[i] - 1] = True
	print(*res)


t = int(input())

def new(x):
	seen.add(x)
	return x
for _ in range(t):
	n = int(input())
	arr = tuple(input().split())
	seen = set()
	print(' '.join([new(x) for x in arr if x not in seen]))


T = int(input())
while T > 0:
	n = int(input())
	lt = list(map(int, input().split()))
	lt2 = []
	for i in lt:
		if i not in lt2:
			lt2.append(i)
	for i in lt2:
		print(i, end=' ')
	print('')
	T -= 1


t = int(input())
for t1 in range(t):
	li = list()
	n = int(input())
	num = list(map(int, input().split()))
	for data in num:
		if data not in li:
			li.append(data)
	for data in li:
		print(data, end=' ')
	print('')


t = int(input())
for i in range(t):
	m = int(input())
	a = list(map(int, input().split()))
	b = []
	n = len(a)
	b.append(a[0])
	for i in range(1, n):
		if a[i] in b:
			pass
		else:
			b.append(a[i])
	for i in b:
		print(i, end=' ')
	print()


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	p = []
	for a in A:
		if a not in p:
			p.append(a)
			print(a, end=' ')
	print()


Number = int(input())
for j in range(Number):
	a = int(input())
	m = list(map(int, input().split()))
	array = []
	for j in m:
		if j not in array:
			array.append(j)
	print(*array)


for _ in range(int(input())):
	length = int(input())
	array = input().split()
	result = []
	for i in array:
		if i not in result:
			result.append(i)
	print(' '.join(result))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	for i in range(0, len(a) - 1):
		for j in range(i + 1, n + 1):
			if a[i] == a[j]:
				a.pop(j)
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	was = [0 for _ in range(n + 1)]
	ans = []
	for elem in a:
		if was[elem] == False:
			ans.append(elem)
			was[elem] = True
	print(' '.join(map(str, ans)))


n = int(input())
for i in range(n):
	num = int(input())
	line = [int(n) for n in input().split()]
	l = []
	j = 0
	while len(line) != len(set(line)):
		if line[j] in l:
			j += 1
			continue
		else:
			l.append(line.pop(j))
	for i in range(num):
		print(f'{l[i]} ', end='')
	print()


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
rli = lambda : map(int, stdin.readline().split())
rlf = lambda : map(float, stdin.readline().split())
(INF, NINF) = (float('inf'), float('-inf'))

def main():
	T = int(rl())
	for _ in range(T):
		n = int(rl())
		(P1, P2) = ([], [])
		seen = defaultdict(lambda : False)
		A = list(rli())
		for x in A:
			if seen[x]:
				P2.append(x)
			else:
				P1.append(x)
				seen[x] = True
		print(' '.join((str(x) for x in P1)))
	stdout.close()
main()


from collections import OrderedDict
T = int(input())
while T > 0:
	x = input()
	n = [int(x) for x in input().split()]
	ans = list(OrderedDict.fromkeys(n))
	for i in ans:
		print(i, end=' ')
	print()
	T -= 1


for t in range(int(input())):
	p = int(input())
	res = []
	for i in list(map(int, input().split())):
		if i not in res:
			res.append(i)
	for i in res:
		print(i, end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	li = [int(i) for i in input().split(' ')]
	li1 = []
	for i in li:
		if i not in li1:
			li1.append(i)
	for i in li1:
		print(i, end=' ')
	t = t - 1


t = int(input())
for _ in range(0, t):
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	d = {}
	ans = []
	for i in range(0, len(arr)):
		d[arr[i]] = d.get(arr[i], 0) + 1
		if d[arr[i]] > 1:
			continue
		else:
			ans.append(arr[i])
	print(*ans)


t = int(input())
for i in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	op = [0] * (n + 1)
	k = []
	for i in range(0, len(a)):
		if op[a[i]] == 0:
			k.append(a[i])
			op[a[i]] = 1
		else:
			continue
	print(*k)


def getIntList(lst):
	assert type(lst) is list
	rep = []
	for i in lst:
		rep.append(int(i))
	return rep
t = int(input())
cnt = 0
while cnt < t:
	cnt += 1
	inputSet = set()
	input()
	lst = getIntList(input().split(' '))
	output = list()
	for item in lst:
		setLength = len(inputSet)
		inputSet.add(item)
		if setLength < len(inputSet):
			output.append(item)
	for item in output:
		print(item, end=' ')
	print('')


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil
from collections import Counter as cs
input = stdin.readline

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list_inp(int)
	ans = []
	for i in arr:
		if i not in ans:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


for i in range(int(input())):
	input()
	l = input().split()
	s = []
	for j in l:
		if j not in s:
			s.append(j)
	print(' '.join(s))


n = int(input())
for i in range(n):
	input()
	s = list(input().split(' '))
	prov = []
	d = []
	for k in s:
		if k not in prov:
			d.append(k)
			prov.append(k)
		else:
			prov.remove(k)
	print(' '.join(d))


for _ in range(int(input())):
	n = int(input())
	permutation = list(map(int, input().split()))
	result = list(dict.fromkeys(permutation).keys())
	resultToStr = ' '.join(map(str, result))
	print(resultToStr)


t = int(input())
for case in range(t):
	z = []
	n = int(input())
	a = list(map(int, input().split()))
	for val in a:
		if val not in z:
			z.append(val)
	print(*z)


for t in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	ans = set()
	for i in lst:
		if i in ans:
			continue
		else:
			print(i, end=' ')
			ans.add(i)
	print()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = []
	for i in range(1, n + 1):
		k.append([a.index(i), i])
	k.sort()
	for i in range(len(k)):
		print(k[i][1], end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(k) for k in input().split()]
	l = [0] * (2 * n)
	l1 = []
	for i in a:
		if l[i - 1] == 0:
			l1.append(i)
		l[i - 1] += 1
	print(*l1)


def restore_perm(array):
	perm = []
	while len(array) > 0:
		perm += [array[0]]
		while perm[-1] in array:
			array.remove(perm[-1])
	return ' '.join(map(str, perm))
t = int(input())
res = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	res += [restore_perm(a)]
print(*res, sep='\n')


def solver(arr):
	result = {}
	ans = []
	for i in arr:
		if i not in result:
			ans.append(i)
		result[i] = True
	print(*ans)
t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	solver(arr)
	t -= 1


from sys import stdin, stdout

def read_input():
	lines = []
	for line in stdin:
		if 'exit' == line.lower().rstrip():
			break
		lines.append(line.rstrip())
	return lines

def write(s):
	stdout.write(s + '\n')

def finish():
	stdout.flush()
lines = read_input()
t = int(lines[0])
for i in range(1, 2 * t + 1, 2):
	n = int(lines[i])
	a = map(int, lines[i + 1].split())
	seen = set()
	ans = []
	for num in a:
		if num not in seen:
			ans.append(num)
			seen.add(num)
	s = ''.join([str(x) + ' ' for x in ans])
	write(s)
finish()


for I in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dic = {}
	for num in a:
		if num not in dic:
			dic[num] = 1
	dic = list(dic)
	print(*dic)


for _ in range(int(input())):
	input()
	lst = list(map(int, input().split()))
	isFirst = [True for x in range(len(lst) // 2)]
	ans = []
	for v in lst:
		if isFirst[v - 1]:
			ans.append(v)
			isFirst[v - 1] = False
	for v in ans:
		print(v, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = tuple(map(int, input().split()))
	hash = [0] * (n + 1)
	ans = []
	for x in arr:
		if hash[x] == 0:
			hash[x] = 1
			ans.append(x)
	print(*ans)


T = int(input())

def printArr(arr):
	ans = ''
	for el in arr:
		ans += str(el) + ' '
	print(ans)
while T > 0:
	n = int(input())
	arr = [int(el) for el in input().split(' ')]
	sol = []
	for el in arr:
		if sol.count(el) == 0:
			sol.append(el)
	printArr(sol)
	T -= 1


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = [a[0]]
	j = 1
	while j < 2 * n:
		if a[j] not in p:
			p.append(a[j])
			j = j + 1
		else:
			j = j + 1
	print(*p)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')

def solve(n, a):
	m = 2 * n
	v = [False] * n
	res = []
	for i in range(m):
		if not v[a[i] - 1]:
			res.append(a[i])
			v[a[i] - 1] = True
	return res

def main():
	for _ in range(ri()):
		n = ri()
		a = ria()
		wia(solve(n, a))
main()


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	V = set()
	p = []
	for v in A:
		if v in V:
			continue
		V.add(v)
		p.append(v)
	print(*p)


def solve():
	n = input()
	a = list(map(int, input().split()))
	b = []
	d = {}
	for i in a:
		if i not in d:
			b.append(i)
			d[i] = True
	for i in b:
		print(i, end=' ')
	print()
for _ in range(int(input())):
	solve()


a = int(input())
for i in range(a):
	x = int(input())
	m = list(map(int, input().split()))
	d = {}
	for i in m:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for (i, j) in d.items():
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	p = [array[0]]
	count = 0
	for i in range(1, 2 * n):
		if array[i] in p:
			count += 1
			continue
		else:
			p.append(array[i])
	print(*p)


try:
	t = int(input())
	for v in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		dic = {}
		for i in range(len(a)):
			if a[i] not in dic:
				dic[a[i]] = 0
		for (k, v) in dic.items():
			print(k, end=' ')
		print()
except:
	pass


import sys
line = sys.stdin.readline

def answer(length, integers):
	list = []
	i = 0
	while len(list) < length:
		if not integers[i] in list:
			list.append(integers[i])
		i += 1
	for num in list:
		print(num, end=' ')
	print()
for i in range(int(line())):
	length = int(line())
	integers = [int(num) for num in line().split(' ')]
	answer(length, integers)


t = int(input())
for i in range(t):
	n = int(input())
	num = list(map(int, input().split()))
	list_set = set(num)
	for i in list_set:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n1 = int(input())
	n = 2 * n1
	l = list(map(int, input().split()))[:n]
	r = []
	for i in range(n):
		k = 0
		temp = l[i]
		for j in range(len(r)):
			if len(r) == n1:
				k = 1
				break
			if temp == r[j]:
				k = 1
		if k == 0:
			r.append(temp)
	for i in range(n1):
		print(r[i], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	k = []
	for m in range(2 * n):
		for j in range(len(arr)):
			if arr[j] not in list(k):
				k.append(arr[j])
			else:
				j += 1
	print(*k[:n])


t = int(input())
for i in range(t):
	n = int(input())
	sete = [int(i) for i in input().split()]
	sete2 = []
	for i in range(len(sete)):
		if sete[i] not in sete2:
			sete2.append(sete[i])
	print(*sete2)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	count = [0] * (n + 1)
	res = []
	for a in A:
		count[a] += 1
		if count[a] == 2:
			res.append(a)
	print(*res)


for _ in range(int(input())):
	size = int(input())
	lis = list(map(int, input().split()))
	se = set()
	for i in lis:
		if i not in se:
			se.add(i)
			print(i, end=' ')
	print()


testcases = int(input())
for _ in range(testcases):
	N = int(input())
	numbers = input().split()
	mapping = dict()
	result = []
	for i in numbers:
		if i not in mapping:
			mapping[i] = 1
			result.append(i)
	result = ' '.join(result)
	print(result)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	res = []
	for j in p:
		if j not in res:
			res.append(j)
	print(*res, sep=' ')


for _ in range(int(input())):
	a = int(input())
	s = list(map(int, input().split()))
	c = [s.index(x + 1) for x in range(a)]
	c.sort()
	for x in c:
		print(s[x], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	seq = list(map(int, input().split()))
	n = list()
	for a in seq:
		if a not in n:
			n.append(a)
	print(*n)


t = int(input())
for _ in range(t):
	n = int(input())
	line = input()
	ar = line.split()
	ar = [int(i) for i in ar]
	ans = list()
	pil = dict()
	for i in ar:
		pil[i] = pil.get(i, 0) + 1
		if pil[i] == 1:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for k in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	li = []
	for j in range(2 * n):
		if p[j] not in li:
			li.append(p[j])
	print(*li)


def ques1(n, a):
	l = []
	for i in range(2 * n):
		if a[i] not in l:
			l.append(a[i])
	print(*l)
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = ques1(n, a)
	ans


t = int(input())
while t > 0:
	n = int(input())
	perm = input().split(' ')
	uniq = []
	uni = set()
	for p in perm:
		if int(p) not in uniq:
			uniq.append(int(p))
	for i in uniq:
		print(i, end=' ')
	print('')
	t -= 1


n = int(input())
for i in range(n):
	z = int(input())
	l = list(map(int, input().split()))
	k = []
	for j in range(len(l)):
		if l[j] in l[0:j]:
			j = j + 1
		else:
			k.append(l[j])
	print(' '.join(map(str, k)))


num_test = input()
solutions = []
for i in range(0, int(num_test)):
	n = input()
	string_2n = input()
	string_2n_list = string_2n.split(' ')
	solution = []
	char_set = set()
	for char in string_2n_list:
		if char not in char_set:
			char_set.add(char)
			solution.append(char)
	solutions.append(' '.join(solution))
for solution in solutions:
	print(solution)


from sys import stdin, stdout
import functools
import sys, os, math
T = int(input())
for _ in range(T):
	N = int(input())
	A = map(int, input().split())
	B = []
	for a in A:
		if a not in B:
			B.append(a)
	for b in B:
		print(b, end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a = []
	b = []
	s = set()
	for i in range(2 * n):
		if arr[i] not in s:
			s.add(arr[i])
			a.append(arr[i])
		else:
			b.append(arr[i])
	print(*a)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	temp = [False for i in range(n + 1)]
	p = list()
	for x in a:
		if temp[x] == False:
			p.append(x)
			temp[x] = True
	for x in p:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	t = list(map(int, input().split()))
	v = [0] * (n + 1)
	order = []
	for i in range(n * 2):
		if v[t[i]] == 0:
			v[t[i]] = 1
			print(t[i], end=' ')
	print()


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	while n > 0:
		t = a[0]
		b.append(t)
		a.remove(t)
		a.remove(t)
		n -= 1
	for i in range(len(b)):
		print(b[i], end=' ')
	print()
ct = int(input())
while ct > 0:
	solve()
	ct -= 1


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for j in range(len(a)):
		if a[j] not in l:
			l.append(a[j])
	for j in range(len(l)):
		print(l[j], sep=' ')
	print()


try:
	from collections import OrderedDict
	n = int(input())
	for i in range(n):
		m = int(input())
		l = list(map(int, input().split()))
		res = list(OrderedDict.fromkeys(l))
		for z in res:
			print(z, end=' ')
		print('')
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	visited = set()
	for i in range(2 * n):
		if not a[i] in visited:
			ans.append(str(a[i]))
			visited.add(a[i])
	print(' '.join(ans))


t = int(input())
for i in range(0, t):
	n = int(input())
	res = []
	a = [int(j) for j in input().split()]
	for j in a:
		if j not in res:
			res.append(j)
	for k in range(0, len(res)):
		print(res[k], end=' ')
	print()


t = int(input())
for ii in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	vis = [0] * n
	ans = []
	for i in range(2 * n):
		if vis[a[i] - 1] == 0:
			vis[a[i] - 1] = 1
			ans.append(a[i])
	for i in range(n - 1):
		print(ans[i], end=' ')
	print(ans[n - 1])


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))[:2 * n]

	def unique(sequence):
		seen = set()
		return [x for x in sequence if not (x in seen or seen.add(x))]
	un = unique(a)
	print(*un)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	se = set()
	ans = list()
	for a in arr:
		if a not in se:
			ans.append(a)
			se.add(a)
	for a in ans:
		print(a, end=' ')
	print()


def restorer_list(l):
	out = []
	for i in l:
		if i not in out:
			out.append(i)
	print(*out)
for _ in range(int(input())):
	n = int(input())
	restorer_list(list(map(int, input().split())))


t = int(input())
while t > 0:
	temp = []
	n = int(input())
	l = input().split(' ')
	arr = list(map(int, l))
	for i in arr:
		if i not in temp:
			temp.append(i)
	t -= 1
	temp = list(map(str, temp))
	s = ' '.join(temp)
	print(s)


from sys import stdin
input = stdin.readline
T = int(input())
for case in range(T):
	n = int(input())
	Visited = [False] * (n + 1)
	line = [*map(int, input().split())]
	Ans = []
	for idx in line:
		if not Visited[idx]:
			Visited[idx] = True
			Ans.append(idx)
	print(*Ans)


t = int(input())
for i in range(t):
	n = int(input())
	p = [int(i) for i in input().split()]
	s = set()
	o = []
	for i in p:
		if i in s:
			o.append(i)
		else:
			s.add(i)
	print(*o)


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	d = dict()
	r = []
	for i in li:
		if i in d:
			continue
		else:
			r.append(i)
			d[i] = 1
	print(*r)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	dic = {}
	ans = []
	for i in range(2 * n):
		if arr[i] not in dic:
			ans.append(arr[i])
			dic[arr[i]] = 1
	for i in ans:
		print(i, end=' ')
	print()


def merge_remove(ara):
	if len(ara) == 1:
		return ara
	m = len(ara) // 2
	left = merge_remove(ara[:m])
	right = merge_remove(ara[m:])
	ans = merge(left, right)
	return ans

def merge(left, right):
	d = []
	i = 0
	while i < len(left):
		if left[i] in right:
			right.remove(left[i])
		d.append(left[i])
		i += 1
	if len(right) > 0:
		d += right
	return d
t = int(input())
while t != 0:
	length = int(input())
	num = list(map(int, input().split()))
	ans = list()
	ans = merge_remove(num)
	for n in ans:
		print(n, end=' ')
	print()
	t -= 1


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		n = iin()
		l = ain()
		x = [0] * (n + 1)
		d = deque([])
		for i in range(2 * n):
			if x[l[i]] == 0:
				x[l[i]] = 1
				d.append(l[i])
		print(*d)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	x = [int(x) for x in input().split()]
	a = []
	for i in x:
		if len(a) < n:
			if i not in a:
				a.append(i)
		else:
			break
	print(*a)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	a = get_array()
	d = defaultdict(int)
	ans = []
	for i in a:
		if d[i] > 0:
			ans.append(i)
		else:
			d[i] += 1
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
tests = []
for i in range(t):
	n = int(input())
	l = input().split()
	tests.append(l)
print('')
for perm in tests:
	sol = []
	for i in perm:
		if i not in sol:
			sol.append(i)
	print(' '.join(sol))


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = [int(x) for x in input().split()]
	table = []
	for x in l1:
		if x not in table:
			table.append(x)
		if len(table) == n:
			break
	print(*table)


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def solve():
	n = II()
	li = L()
	d = {}
	for ele in li:
		if d.get(ele, -1) == -1:
			print(ele, end=' ')
			d[ele] = d.get(ele, 0) + 1
	print()
t = II()
for i in range(t):
	solve()


import math as mt

def tran(arr):
	an = []
	for i in range(len(arr)):
		if arr[i] not in an:
			an.append(arr[i])
	return an
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	r = tran(arr)
	ans.append(r)
for i in ans:
	print(*i)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(input().split())
	ans = []
	for el in a:
		if el not in ans:
			ans.append(el)
	print(*ans)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	ans = []
	for i in a:
		if i not in s:
			ans.append(i)
			s.add(i)
	print(*ans, sep=' ')


def Cloning(li1):
	li_copy = li1[:]
	return li_copy

def main():
	t = int(input())
	for i in range(1, t + 1):
		n = int(input())
		a = list(map(int, input().split()))
		store = dict()
		p = list()
		for i in a:
			store[i] = 2
			if len(store) == n:
				break
		for (i, count) in store.items():
			if count == 2:
				p.append(i)
				count = 1
		for i in p:
			print(i, end=' ')
main()


def permutation(arr, n):
	res = list(dict.fromkeys(arr))
	return res
t = int(input())
for t_itr in range(t):
	n = int(input())
	arr = map(int, input().rstrip().split())
	result = permutation(arr, n)
	print(*result, sep=' ')


t = int(input())
answer = []
for i in range(t):
	n = int(input())
	p = list(input().split(' '))
	po = [p[0]]
	check = 0
	for i in p:
		if p.index(i) > check:
			po.append(i)
			check = p.index(i)
	answer.append(po)
for i in answer:
	for j in i:
		print(j, end=' ')
	print('')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	boo = []
	for j in range(2 * n):
		boo.append(True)
	ans = []
	k = 0
	while k != 2 * n:
		if boo[k] == True:
			x = l[k]
			ans.append(x)
			boo[k] = False
			y = l[k + 1:].index(x) + k + 1
			boo[y] = False
		k += 1
	z = ''
	for sol in ans:
		z = z + str(sol) + ' '
	print(z)


for k in [*open(0)][2::2]:
	print(*{*k.split()})


for _ in range(int(input())):
	input()
	arr = list(map(int, input().split()))
	ans = []
	for data in arr:
		if data not in ans:
			ans.append(data)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = list(input().split())
	l1 = []
	for i in range(n * 2):
		if l[i] not in l1:
			l1.append(l[i])
	print(*l1)


t = int(input())
while t:
	n = int(input())
	li = [int(x) for x in input().split()]
	new = []
	for value in li:
		if value not in new:
			new.append(value)
	print(*new)
	t -= 1


from collections import OrderedDict
for _ in range(int(input())):
	n = int(input())
	seq = list(map(int, input().split()))
	h = OrderedDict()
	for i in seq:
		if i in h:
			pass
		else:
			h[i] = 1
	for keys in h.keys():
		print(keys, end=' ')


t = int(input(''))
mat = []
for i in range(t):
	int(input(''))
	mat.append(list(map(int, input().split())))
for i in range(t):
	x = mat[i]
	n = int(len(x) / 2)
	flag = [0] * n
	ans = []
	for j in range(2 * n):
		if flag[x[j] - 1] == 0:
			ans.append(x[j])
			flag[x[j] - 1] = 1
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().strip().split(' ')))
	d = {}
	ll = []
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
			ll.append(i)
	print(*ll)


import sys
q = int(input())
for i in range(q):
	n = int(sys.stdin.readline())
	a = [int(j) for j in sys.stdin.readline().split()]
	mass = [0] * n
	s = []
	for i in range(2 * n):
		mass[a[i] - 1] += 1
		if mass[a[i] - 1] == 2:
			s.append(a[i])
	print(*s)


for _ in range(int(input())):
	s = input()
	a = []
	a = list(map(int, input().split()))
	d = set(a)
	ans = ''
	for i in a:
		if i in d:
			ans += str(i) + ' '
			d.remove(i)
	print(ans)


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	brr = []
	for i in arr:
		if len(brr) == n:
			break
		if not i in brr:
			brr.append(i)
	print(*brr)


for _ in range(int(input())):
	n = int(input())
	l = input().split()
	t = []
	for i in l:
		if i not in t:
			t += [i]
	print(' '.join(t))


n = int(input())
for i in range(n):
	m = int(input())
	s = list(map(int, input().split()))
	d = {}
	arr = []
	for a in s:
		if a not in d.keys():
			arr.append(a)
			d[a] = 1
	for a in arr:
		print(a, end=' ')
	print()


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
MOD = 998244353
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	d = {}
	ans = []
	for i in range(2 * n):
		if a[i] in d:
			continue
		ans.append(a[i])
		d[a[i]] = True
	for i in range(n):
		print(ans[i], end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	for i in arr:
		if i in d.keys():
			continue
		else:
			print(i, end=' ')
			d[i] = 1
	print()


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	s1 = set()
	for i in l:
		if i not in s1:
			l1.append(i)
			s1.add(i)
	for i in l1:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	freq = (n + 1) * [-1]
	res = []
	for i in l:
		freq[i] += 1
		if freq[i]:
			res.append(i)
	for i in res:
		print(i, end=' ')
	print()


def getAns(n, a):
	ans = [0] * n
	dst = 0
	b = set()
	for ai in a:
		if ai in b:
			continue
		b.add(ai)
		ans[dst] = ai
		dst += 1
	return ' '.join(map(str, ans))

def main():
	t = int(input())
	anss = [''] * t
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		anss[i] = getAns(n, a)
	for ans in anss:
		print(ans)
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	freq = [0] * (n + 1)
	ans = []
	for i in a:
		if freq[i] == 0:
			ans.append(i)
			freq[i] += 1
	print(*ans)


cases = int(input())
for _ in range(cases):
	_ = input()
	nums = input()
	f = nums.split(' ')
	d = dict()
	seq = []
	for num in f:
		d[num] = d.get(num, 0) + 1
		if d[num] % 2 == 0:
			seq.append(num)
	print(' '.join(seq))


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	found = [0 for x in range(n + 1)]
	ans = []
	for x in arr:
		if found[x] == 0:
			found[x] = 1
			ans.append(x)
	for x in ans:
		print(x, end=' ')
	print()


def solve(a, n):
	temp = dict()
	res = list()
	for i in a:
		temp[i] = 1
	for i in a:
		if i in temp.keys() and i not in res:
			res.append(i)
	return res
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	res = solve(a, n)
	for i in res:
		print(i, end=' ')
	print(end='\n')


t = int(input())
for i in range(t):
	n = int(input())
	ar = [int(i) for i in input().split()]
	pri = []
	ha = set(ar)
	for x in range(2 * n):
		if (ar[x] in ha) == True:
			pri.append(ar[x])
			ha.remove(ar[x])
		else:
			pass
	print(' '.join((str(i) for i in pri)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	d = {}
	for x in a:
		d[x] = d.get(x, 0) + 1
		if d[x] == 1:
			ans.append(x)
	print(*ans)


n = int(input())
for i in range(n):
	b = int(input())
	b = input().split()
	d = []
	for i in b:
		if i not in d:
			d.append(i)
	print(' '.join(d))


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
for case in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	p = []
	seen = set()
	for x in a:
		if x not in seen:
			p.append(x)
			seen.add(x)
	print(' '.join((str(x) for x in p)))


T = int(input())
while T != 0:
	n = int(input())
	N = list(map(int, input().strip().split()))[:2 * n]
	dic = {}
	for i in range(n):
		dic[i + 1] = -1
	count = 0
	for i in range(2 * n):
		if dic[N[i]] == -1:
			dic[N[i]] = count
			count += 1
	ans = [0] * n
	for i in dic:
		ans[dic[i]] = i
	print(*ans)
	T -= 1


t = int(input())
while t:
	n = int(input())
	nums = list(map(int, input().split(' ')))
	order = []
	for i in nums:
		if i not in order:
			order.append(i)
	print(*order, sep=' ')
	t -= 1


num = int(input())
for i in range(num):
	length = int(input())
	quest = input().split()
	numbers = [int(i) for i in quest]
	s = set()
	array = []
	for j in numbers:
		if j in s:
			continue
		else:
			array.append(j)
			s.add(j)
			print(j, end=' ')
			if len(array) == length:
				break
	print()


for t in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	arr1 = []
	arr2 = []
	arr3 = []
	for i in range(2 * n - 1):
		if num[i] not in arr1:
			arr1.append(num[i])
			arr3.append(str(num[i]))
		else:
			arr2.append(num[i])
	s = ' '.join(arr3)
	print(s)


t = int(input())
list = []
for i in range(t):
	n = int(input())
	l = []
	l = [int(x) for x in input().split()]
	c = []
	s = set()
	for k in l:
		if not k in s:
			c.append(k)
			s.add(k)
	list.append(c)
for l in list:
	for x in l:
		print(x, end=' ')
	print()


for test in range(int(input())):
	n = 2 * int(input())
	a = [int(i) for i in input().split()]
	ans = []
	for i in range(n):
		if a[i] >= 0:
			for j in range(i + 1, n):
				if a[i] == a[j]:
					ans.append(a[i])
					a[i] = -1
					a[j] = -1
	print(*ans)


num = input()
for x in range(int(num)):
	length = int(input())
	nums = list(map(int, input().split()))
	newset = set()
	ans = []
	for x in nums:
		if x in newset:
			ans.append(x)
		else:
			newset.add(x)
	print(' '.join((str(x) for x in ans)))


t = int(input())
while t:
	t += -1
	n = int(input())
	l = list(map(int, input().split()))
	vis = [0] * (n + 1)
	ans = []
	for i in l:
		if vis[i] == 0:
			vis[i] = 1
			ans.append(i)
	print(*ans)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	p = list(map(int, input().split()))
	(check, ans) = ([], [])
	for i in range(len(p)):
		if p[i] in check:
			del check[check.index(p[i])]
		else:
			check.append(p[i])
			ans.append(p[i])
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	has = [-1] * 51
	ans = []
	x = list(map(int, input().split()))
	for i in x:
		if has[i] != -1:
			print(i, end=' ')
		has[i] = 0
	print()


def unique(list1):
	unique_list = []
	for x in list1:
		if x not in unique_list:
			unique_list.append(x)
	print(*unique_list)
t = int(input())
for test in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	unique(l)


n = int(input())
arr = []
for i in range(n):
	l = int(input())
	a = list(input().split(' '))
	k = 0
	g = []
	while k < len(a):
		if g.count(int(a[k])) == 0:
			g.append(int(a[k]))
		k += 1
	arr.append(g)
for i in range(len(arr)):
	for l in range(len(arr[i])):
		if l != len(arr[i]) - 1:
			print(arr[i][l], end=' ')
		else:
			print(arr[i][l])


import sys
input = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = []
	for x in a:
		if x not in b:
			b.append(x)
	print(*b)


for testcases in range(1, int(input()) + 1):
	n = int(input())
	ar = list(map(int, input().split()))
	flag = [0 for i in ar]
	a = []
	b = []
	for i in ar:
		if flag[i] == 0:
			flag[i] += 1
			a.append(i)
	for i in a:
		print(i, end=' ')
	print()


t = int(input(''))
for l in range(t):
	n = int(input(''))
	st = input('')
	s = st.split(' ')
	li = list()
	for i in s:
		li.append(int(i))
	li1 = list()
	for k in li:
		if k not in li1:
			li1.append(k)
	for k in li1:
		print(k, end=' ')
	print()


n = int(input())
numbers = []
for i in range(n):
	input()
	temp = list(map(int, input().split()))
	temp = list(dict.fromkeys(temp))
	numbers.append(temp)
for number in numbers:
	print(*number, sep=' ')


def findarr(x):
	arr = []
	for i in range(len(x)):
		if str(x[i]) not in arr:
			arr.append(str(x[i]))
	return arr
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))[:2 * n]
	result = findarr(a)
	print(' '.join(result))


import math
t = int(input())
for i in range(t):
	string = ''
	n = int(input())
	list1 = input().split()
	for i in range(len(list1)):
		list1[i] = int(list1[i])
	done = [0 for x in range(n)]
	for i in range(len(list1)):
		if done[list1[i] - 1] == 0:
			string += str(list1[i])
			string += ' '
			done[list1[i] - 1] = 1
	print(string)


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
from heapq import heapify, heappop, heappush, heapreplace, heappushpop

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
mod = 1000000007
res = ['YES', 'NO']
test = 1
test_case = ii()
while test <= test_case:
	test += 1
	n = ii()
	a = li()
	s = set()
	ans = []
	for i in a:
		if i not in s:
			ans.append(i)
			s.add(i)
	print(*ans)


a = int(input())
for i in range(a):
	n = int(input())
	li = list(map(int, input().split()))
	x = []
	for element in li:
		if element not in x:
			x.append(element)
		else:
			m = 0
	print(*x, sep=' ')


te = int(input())
for i in range(te):
	n = input()
	l = input().split(' ')
	l = list(map(int, l))
	l1 = []
	l2 = []
	for j in l:
		if j not in l1:
			l1.append(j)
	for j in l1:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	output = []
	s = ''
	for i in b:
		if i not in output:
			output.append(i)
	for i in output:
		s += str(i) + ' '
	print(s)


t = int(input())
a = []
f = ''
for i in range(t):
	p = int(input())
	a = [int(x) for x in input().split()]
	s = [0] * (p + 1)
	for i in range(len(a)):
		if s[a[i]] == 0:
			s[a[i]] += 1
			f += str(a[i]) + ' '
	print(f)
	f = ''


for i in range(int(input())):
	n = int(input())
	s = [int(i) for i in input().split()]
	for i in range(1, n + 1):
		s.pop(s.index(i))
	print(*s)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	visited = set()
	ans = list()
	for num in arr:
		if num not in visited:
			ans.append(num)
			visited.add(num)
	print(*ans, sep=' ')


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(j) for j in input().split()]
	ans = []
	for j in arr:
		if j not in ans:
			ans.append(j)
	print(*ans)


def run():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = [int(i) for i in input().split()]
		ans = []
		rep = {}
		for num in a:
			if num not in rep:
				ans.append(num)
				rep[num] = 0
		print(*ans)
run()


t = int(input())
for _ in range(t):
	tam = int(input())
	num = [int(i) for i in input().split()]
	(ans, a) = ([], [False] * tam * 2)
	for j in num:
		if not a[j]:
			ans.append(j)
			a[j] = True
	print(' '.join(map(str, ans)))


for _ in range(int(input().strip())):
	n = input()
	l = list(map(int, input().strip().split(' ')))
	d = {}
	for i in l:
		d[i] = 1
	print(' '.join(list(map(str, d.keys()))))


import collections
for _ in range(int(input())):
	_ = input()
	print(*(num for num in collections.Counter(input().split())))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(1, n + 1):
		b.append(a.index(i))
	for i in range(2 * n):
		if i in b:
			print(b.index(i) + 1, end=' ')


import collections
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	print(*list(collections.OrderedDict.fromkeys(l)))


from sys import stdin, stdout
import math
input = stdin.readline

def print(x='', y='', end='\n'):
	if y == '':
		stdout.write(str(x) + end)
	else:
		stdout.write(str(x) + ' ' + str(y) + end)

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	used = [False] * (n + 1)
	ans = []
	for i in l:
		if not used[i]:
			ans.append(i)
			used[i] = True
	for i in ans:
		print(i, end=' ')
	print()
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


import sys
input = sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input().strip('\n'))
si = lambda : input().strip('\n')
dgl = lambda : list(map(int, input().strip('\n')))
f = lambda : map(int, input().strip('\n').split())
il = lambda : list(map(int, input().strip('\n').split()))
ls = lambda : list(input().strip('\n'))
lsc = lambda : list(input().strip('\n').split(' '))
lsi = lambda : [int(i) for i in ls()]
let = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(ii()):
	n = ii()
	l = il()
	ans = [l[0]]
	for i in range(1, 2 * n):
		if not l[i] in ans:
			ans.append(l[i])
	print(*ans)


for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	s = list(set(lst))
	print(*s)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	dict = {}
	l = []
	for i in arr:
		if i in dict:
			dict[i] += 1
		else:
			dict[i] = 1
			l.append(i)
	print(*l)


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	n = ri()
	a = rl()
	p = []
	s = set()
	for i in range(2 * n):
		if a[i] not in s:
			p.append(a[i])
			s.add(a[i])
	print(*p)


T = int(input())
for i in range(T):
	n = int(input())
	arr = [int(x) for x in input().split()]
	li = []
	for j in arr:
		if j not in li:
			li.append(j)
	print(*li)


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')
tests = lambda : range(1, int_in() + 1)
case_out = lambda i, o: out('Case #{}: {}'.format(i, o))

def solve(n, a):
	seen = set()
	p1 = []
	p2 = []
	for item in a:
		if item in seen:
			p2.append(item)
		else:
			p1.append(item)
			seen.add(item)
	return p1
for _ in tests():
	n = int_in()
	a = arr_in()
	arr_out(solve(n, a))


t = int(input())
answer = []

def main(a):
	(i, start_len) = (0, len(a))
	deleted = []
	while len(deleted) < start_len / 2:
		if a[i] not in deleted:
			deleted.append(a[i])
			del a[i]
			i -= 1
		i += 1
	return a
for _ in range(t):
	start_len = int(input())
	listok = list(input().split())
	answer.append(main(listok))
for ans in answer:
	print(' '.join(ans))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	b = [True] * (n + 1)
	r = []
	for i in mints():
		if b[i]:
			b[i] = False
			r.append(i)
	print(' '.join(map(str, r)))
for i in range(mint()):
	solve()


t = int(input())
final = []
for i in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	a = []
	b = []
	for i in range(2 * n):
		if len(a) == n:
			break
		elif l[i] not in a:
			a.append(l[i])
	final.append(a)
for i in range(t):
	print(*final[i])


import sys
input = lambda : sys.stdin.readline()
exec("try:sys.stdin=open('in.txt','r');sys.stdout=open('out.txt','w')\nexcept:pass")
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	ans = []
	for i in a:
		if i not in s:
			ans.append(i)
			s.add(i)
	print(*ans)


import math
t = int(input())
for i in range(t):
	l = int(input())
	arr = input().split()
	sol = list()
	for i in arr:
		if not i in sol:
			sol.append(i)
	print(' '.join(sol))


def fun(l, l1):
	l2 = []
	for j in range(len(l1)):
		if l1[j] in l2:
			continue
		else:
			l2.append(l1[j])
			if len(l2) == l:
				break
	return l2
n1 = int(input())
for _ in range(n1):
	n2 = int(input())
	n3 = input()
	l1 = []
	for i in range(2 * n2):
		l1.append(int(n3.split()[i]))
	x = fun(n2, l1)
	for item in x:
		print(item, end=' ')
	print()


n = int(input(''))
for i in range(n):
	z = int(input(''))
	c = input().split()
	di = dict()
	for w in c:
		if w not in di:
			di[w] = 1
			print(w, end=' ')


for _ in range(int(input())):
	n = int(input())
	t = list(map(int, input().split()))
	l = []
	for i in t:
		if i not in l:
			l += [i]
	print(*l)


t = int(input())
for i in range(t):
	l = []
	n = int(input())
	l = list(map(int, input().strip().split()))
	res = []
	for j in l:
		if j not in res:
			res.append(j)
	print(' '.join(map(str, res)))


t = int(input())
for i in range(t):
	l = int(input())
	lst = [int(x) for x in input().split()]
	ls = [lst[0]]
	j = 1
	while len(ls) < l:
		if lst[j] not in ls:
			ls.append(lst[j])
		j = j + 1
	print(' '.join(map(str, ls)))


def double(array):
	set_array = set(array)
	for c in set_array:
		array.remove(c)
		continue
	return array
n = int(input())
for i in range(n):
	k = int(input())
	lst = list(map(int, input().split()))
	print(*double(lst))


t = int(input())
ans = []
for iter in range(t):
	length = int(input())
	seen = []
	s = input().split(' ')
	for x in s:
		if x not in seen:
			seen.append(x)
	ans.append(seen)
for x in ans:
	s = ''
	for i in range(len(x)):
		if i != len(x) - 1:
			s += x[i] + ' '
		else:
			s += x[i]
	print(s)


t = int(input(''))
for i in range(t):
	n = int(input(''))
	numbers = list(map(int, input('').split(' ')))
	list1 = []
	for i in numbers:
		if i not in list1:
			list1.append(i)
	list2 = [str(i) for i in list1]
	print(' '.join(list2))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def msi():
	return map(str, input().split())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mod = 1000000007

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, sqrt, factorial, cos, tan, sin, radians, ceil, floor
import bisect
from decimal import *
getcontext().prec = 25
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		l = []
		f = [0] * 51
		for i in range(2 * n):
			if f[a[i]]:
				continue
			else:
				f[a[i]] = 1
				l.append(a[i])
		print(*l)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
lst = []
for _ in range(t):
	n = int(input())
	st = list(map(int, input().split()))
	for e in st:
		if e not in lst:
			lst.append(e)
	print(*lst)
	lst.clear()


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))
import math

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math as M
MOD = 10 ** 9 + 7
from random import randint as R
import sys
for _ in range(int(input())):
	n = int(input())
	A = INPUT()
	ans = []
	for i in range(2 * n):
		if A[i] not in ans:
			ans.append(A[i])
	print(*ans)


n = input()
b = int(n)
for i in range(int(b)):
	d = int(input())
	l = list(map(int, input().split()))
	f = []
	for i in l:
		if i not in f:
			f.append(i)
	for i in f:
		print(i, end=' ')
	print('')


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().strip().split()))[:2 * a]
	c = set(b)
	e = []
	for j in range(len(b)):
		if str(b[j]) not in e:
			e.append(str(b[j]))
	print(' '.join(e))


t = int(input())
while t != 0:
	n = int(input())
	nums = list(map(int, input().split(' ')))
	d = dict()
	res = []
	for i in nums:
		if i not in d:
			res.append(i)
			d[i] = 1
	for i in res:
		print(i, end=' ')
	t = t - 1


tc = int(input())
for s in range(tc):
	n = int(input())
	inp = list(map(int, input().split()))
	out = []
	for i in inp:
		if i not in out:
			out.append(i)
	print(*out)


t = int(input(''))
for test in range(t):
	m = int(input(''))
	k = list()
	a = input('')
	a = a.split()
	for el in a:
		k.append(int(el))
	pr = list()
	for el in a:
		if el in pr:
			continue
		pr.append(el)
	for el in pr:
		print(el, end=' ')
	print()


n = int(input())
for x in range(n):
	l = []
	a = int(input())
	p = list(map(int, input().strip().split()[:2 * a]))
	for y in p:
		if y not in l:
			l.append(y)
	print(*l)


n = int(input())
for _ in range(n):
	a = int(input())
	lis = list(map(int, input().split()))
	lis2 = []
	for i in lis:
		if i not in lis2:
			lis2.append(i)
	for i in lis2:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	got = []
	for i in nums:
		if i not in got:
			got.append(i)
	print(*got)


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(0, len(a)):
		if a[i] not in b:
			b.append(a[i])
	for i in b:
		print(i, end=' ')
	print()


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = input().split()
		p = [a[0]]
		for i in a:
			if i not in p:
				p.append(i)
		print(' '.join(p))
main()


from math import log2, ceil, floor
from collections import defaultdict, OrderedDict, Counter, deque
from heapq import heappush, heappop, heapify

def str_inp():
	return input()

def list_inp():
	return list(map(int, input().split()))

def map_inp():
	return map(int, input().split())

def int_inp():
	return int(input())

def float_int():
	return float(input())

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
for _ in range(int_inp()):
	n = int_inp()
	p = list_inp()
	ans = []
	for i in range(2 * n):
		if p[i] not in ans:
			ans.append(p[i])
	print(*ans)


tc = int(input())
while tc:
	n = int(input())
	arr = list(map(int, input().split()))
	dict = [0] * n
	for i in range(0, 2 * n):
		if dict[arr[i] - 1]:
			continue
		else:
			dict[arr[i] - 1] = 1
			print(arr[i], end=' ')
	print()
	tc -= 1


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def foo():
	n = inp()
	ans = []
	lst = inlt()
	for (index, item) in enumerate(lst):
		if item not in ans:
			ans.append(item)
	for item in ans:
		print(item, end=' ')
	print('\n')
t = inp()
for i in range(t):
	foo()


def sol(lis):
	elementsDone = set()
	for i in range(len(lis)):
		if lis[i] not in elementsDone:
			elementsDone.add(lis[i])
			print(lis[i], end=' ')
	print()
k = int(input())
for i in range(k):
	input()
	lis = list(map(int, input().split(' ')))
	sol(lis)


b = int(input())
for i in range(b):
	m = input()
	user_input = input().split()
	a = [int(x.strip()) for x in user_input]
	b = [a[0]]
	c = []
	j = 0
	for i in range(1, len(a)):
		if b == c:
			b.append(a[i])
		elif b == c and i == len(a):
			break
		elif b != c and a[i] != b[j]:
			b.append(a[i])
		elif a[i] == b[j]:
			c.append(a[i])
			j += 1
	for x in b:
		print(x, end=' ')


t = int(input())
for i in range(t):
	d = int(input())
	f = list(map(int, input().split()))
	f = list(dict.fromkeys(f))
	for i in f:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	new_li = []
	for i in li:
		if i not in new_li:
			new_li.append(i)
		if len(new_li) == n:
			break
	print(*new_li, sep=' ')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	ind = 0
	for j in range(2 * n):
		f = 0
		for k in d:
			if d[k] == l[j]:
				f = 1
				break
		if f == 0:
			d.update({ind: l[j]})
			ind += 1
	for j in range(n):
		print(d[j], end=' ')


def findA(n, a):
	seen = set()
	ans = []
	for i in range(2 * n):
		if a[i] not in seen:
			ans.append(a[i])
			seen.add(a[i])
		if len(ans) == n:
			break
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = findA(n, a)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	nl = [0] * (2 * n)
	for i in l:
		nl[i] += 1
	for i in range(2 * n):
		if nl[l[i]] > 1:
			print(l[i], end=' ')
		nl[l[i]] -= 1
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().split()))
	for i in range(len(ls)):
		if ls[i] not in ls[:i]:
			print(ls[i], end=' ')
	print()


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	ls = get_list()
	dic = defaultdict(int)
	ans = []
	for val in ls:
		if val not in dic:
			dic[val] = 1
			ans.append(val)
	print(*ans)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


for test in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	a = []
	for i in lst:
		if i not in a:
			a.append(i)
	print(*a)


t = int(input())
for tt in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	c = 0
	i = 0
	s = ''
	while c != n:
		if a[i] not in b:
			b.append(a[i])
			s = s + str(a[i]) + ' '
			c += 1
		i += 1
	print(s)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = defaultdict(lambda : 0)
	result = []
	for i in arr:
		if ans[i] == 0:
			ans[i] += 1
			result.append(i)
	print(*result)


from collections import OrderedDict
for t in range(int(input())):
	n = int(input())
	a = []
	a = list(map(int, input().split()))
	b = list(OrderedDict.fromkeys(a))
	for each in b:
		print(each, end=' ')
	print()


n1 = int(input())
for x in range(n1):
	n2 = int(input())
	n3 = input().split(' ')
	arr = []
	arrfinal = []
	for y in range(2 * n2):
		arr.append(int(n3[y]))
	arrcount = []
	for y in range(n2 + 1):
		arrcount.append(0)
	for y in range(2 * n2):
		if arrcount[arr[y]] == 1:
			continue
		else:
			arrcount[arr[y]] = 1
			arrfinal.append(arr[y])
	for y in arrfinal:
		print(y, end=' ')
	print(' ')


def restoreP(n, array):
	a = []
	i = 0
	for i in range(2 * n):
		aux = 0
		j = 0
		while j < i:
			if array[j] == array[i]:
				aux = 1
				break
			j = j + 1
		if aux == 1:
			continue
		a.append(array[i])
	i = 0
	while i < n:
		print(a[i], end=' ')
		i = i + 1

def main():
	t = int(input())
	r = 0
	while r < t:
		n = int(input())
		sample = input().split()
		l = [int(x) for x in sample]
		restoreP(n, l)
		print()
		r = r + 1
main()


def lp():
	return list(map(int, input().split()))

def ip():
	return int(input())
n = ip()
while n:
	n -= 1
	z = int(input())
	lst = list(map(int, input().split()))
	arr = []
	for i in lst:
		if i in arr:
			pass
		else:
			arr.append(i)
		if len(arr) == z:
			break
	print(*arr)


for i in range(int(input())):
	n = int(input())
	p = list(map(int, input().split()))
	ans = []
	ans.append(p[0])
	for i in range(len(p)):
		flag = True
		for j in range(len(ans)):
			if p[i] == ans[j]:
				flag = False
		if flag == True:
			ans.append(p[i])
	for j in ans:
		print(j, end=' ')
	print()


t = int(input())
while t != 0:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	for i in a:
		if d.get(i) == None:
			d[i] = 1
	d1 = list(d)
	for i in d1:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	check = [0] * (n + 1)
	res = []
	for i in l:
		if not check[i]:
			check[i] = 1
			res.append(i)
	print(*res)


t = int(input())
for _ in range(t):
	n = int(input())
	permutation = [x for x in input().split()]
	seen = set()
	answer = []
	for char in permutation:
		if char in seen:
			answer.append(char)
		else:
			seen.add(char)
	print(' '.join(answer))


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	USE = [0] * (n + 1)
	ANS = []
	for i in range(2 * n):
		if USE[A[i]] == 0:
			ANS.append(A[i])
			USE[A[i]] = 1
	print(*ANS)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(_) for _ in input().split()]
	num = [0] * (n + 1)
	ans = []
	for i in range(n * 2):
		num[a[i]] += 1
		if num[a[i]] == 2:
			ans.append(a[i])
	for i in ans:
		print(i, end=' ')
	print()


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	n = inp()
	l = li()
	k = []
	for i in l:
		if i not in k:
			k.append(i)
	print(*k)
for _ in range(inp()):
	solve()


import sys
input = sys.stdin.readline
INF = float('inf')
tc = int(input())
for _ in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = list()
	for i in arr:
		if i not in ans:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	lens = int(input())
	perm = [int(x) for x in input().split()]
	has = []
	for i in perm:
		if i not in has:
			has.append(i)
	print(*has)


testcases = int(input())
for testcase in range(testcases):
	dicts = {}
	n = int(input())
	temparr = input()
	temparr = temparr.split()
	ans = []
	for i in temparr:
		if i not in dicts:
			dicts[i] = 1
			ans.append(str(i))
	print(' '.join(ans))


for _ in range(int(input())):
	n = input()
	ls = list(map(int, input().split()))
	temp = list()
	temp = list(set(ls))
	print(*temp)


t = int(input())
for i in range(t):
	x = int(input())
	n = list(map(str, input().split()))
	z = []
	for i in range(len(n)):
		if n[i] in z:
			continue
		else:
			z.append(n[i])
	print(' '.join(z))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	for j in l:
		if j in l1:
			pass
		else:
			print(str(j), end='')
			l1.append(j)
			if len(l1) == n:
				break
			else:
				print(end=' ')
	print()


from collections import defaultdict
for _ in ' ' * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(lambda : 0)
	for i in a:
		d[i] += 1
	for (key, value) in d.items():
		print(int(f'{value}') // 2 * key, end=' ')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	temp = []
	for element in l:
		if len(temp) == n:
			break
		if element not in temp:
			temp.append(element)
	for element in temp:
		print(element, end=' ')


from collections import Counter
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = Counter(l)
	lul = list(c.keys())
	print(*lul)


for _ in range(int(input())):
	k = int(input())
	a = list(map(int, input().split()))
	n = 2 * k
	if a[:n // 2] == a[n // 2:]:
		print(*a[:n // 2])
		continue
	ans = []
	chk = [False] * (k + 1)
	for i in a:
		if chk[i] == False:
			chk[i] = True
			ans.append(i)
	print(*ans)


t = int(input())
while t > 0:
	n = int(input())
	l = input().split(' ')
	l = [int(i) for i in l]
	l2 = []
	for e in l:
		if e in l2:
			continue
		else:
			l2.append(e)
	print(*l2)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	o = []
	c = 0
	for i in range(len(p)):
		if p[i] not in o:
			o.append(p[i])
			c += 1
			if c == n:
				break
	print(*o)


def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	set = []
	for num in a:
		if num not in set:
			set.append(num)
	for i in set:
		print(i, end=' ')
	print('')
t = int(input())
for i in range(t):
	solve()


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
for _ in range(int(z())):
	n = int(z())
	l = list(map(int, z().split()))
	nl = []
	for i in l:
		if i not in nl:
			nl.append(i)
	print(*nl)


from sys import stdin
_input = stdin.readline
(_int, _range, _set) = (int, range, set)

def solution():
	for _ in _range(_int(_input())):
		n = _int(_input())
		arr = [_int(i) for i in _input().split()]
		digits = _set()
		ans = []
		for i in _range(n * 2):
			if arr[i] not in digits:
				ans.append(arr[i])
				digits.add(arr[i])
		print(*ans)
solution()


T = int(input())
while T > 0:
	T = T - 1
	n = int(input())
	A = [str(i) for i in input().split()]
	list = []
	for I in range(len(A)):
		if A[I] not in list:
			list.append(A[I])
	for I in range(len(list)):
		print(list[I], end=' ')


a = int(input())
for k in range(a):
	b = int(input())
	c = list(map(int, input().split()))
	d = []
	for k in c:
		if k not in d:
			print(k, end=' ')
			d += [k]
	print()


t = int(input())
while t > 0:
	n = int(input())
	d = [int(x) for x in input().split(' ')]
	uni = []
	for x in d:
		if x not in uni:
			uni.append(x)
	for x in uni:
		print(x, end=' ')
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	ans = []
	for i in nums:
		if i not in ans:
			ans.append(i)
	print(str(ans)[1:-1].replace(',', ''))


def main():
	t = int(input())
	for i in range(0, t):
		input()
		d = list(map(int, input().split()))
		d2 = list()
		for x in d:
			if not x in d2:
				d2.append(x)
		print(' '.join(map(str, d2)))
main()


cases = int(input())
for i in range(0, cases):
	n = int(input())
	case = input().split()
	answer = []
	answer.append(case[0])
	for j in range(1, 2 * n):
		if case[j] not in answer:
			answer.append(case[j])
	print(' '.join(answer))


t = int(input())
for _ in range(t):
	n = int(input())
	seen = [False] * n
	A = list(map(int, input().split()))
	ans = list()
	for a in A:
		if not seen[a - 1]:
			seen[a - 1] = True
			ans.append(a)
	for a in ans:
		print(a, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	temp = []
	for i in range(2 * n):
		if l[i] in d:
			continue
		else:
			d[l[i]] = 1
			temp.append(l[i])
	for i in range(n):
		print(temp[i], end=' ')
	print()


def solve():
	n = int(input())
	arr = [int(v) for v in input().split()]
	ans = []
	st = set()
	for v in arr:
		if not v in st:
			st.add(v)
			ans.append(v)
	print(' '.join((str(v) for v in ans)))
t = int(input())
for _ in range(t):
	solve()


TC = int(input())
for tc in range(TC):
	N = int(input())
	A = list(map(int, input().split()))
	pos = set()
	result = []
	i = 0
	j = 0
	for a in A:
		if a in pos:
			if result[j] != a:
				break
			else:
				j += 1
		else:
			pos.add(a)
			result.append(a)
			i += 1
	for r in result:
		print(r, end=' ')
	print()


t = int(input())
a = []
for i in range(t):
	n = int(input())
	x = []
	x.extend(input().split())
	a.append(x)
	for j in range(len(a[i])):
		a[i][j] = int(a[i][j])
for i in range(t):
	count = 0
	c = []
	for j in range(len(a[i])):
		flag = 0
		for k in range(len(c)):
			if a[i][j] == c[k]:
				flag = 1
		if flag == 0:
			count += 1
			c.append(a[i][j])
	for k in range(len(c)):
		print(c[k], end=' ')
	print('\n', end='')


n = int(input())
for i in range(n):
	x = int(input())
	a = list(map(int, input().split()))
	l = []
	i = 0
	while len(l) < x:
		if a[i] in l:
			i += 1
		else:
			l.append(a[i])
			i += 1
	print(' '.join((str(e) for e in l)))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	check = [x for x in range(1, n + 1)]
	temp = []
	for i in lst:
		if i not in temp and i in check:
			temp.append(i)
		else:
			continue
	for j in range(n):
		print(temp[j], end=' ')


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	seen = set()
	output = []
	for elem in a:
		if elem in seen:
			continue
		seen.add(elem)
		output.append(elem)
	print(' '.join(output))


import math
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from sys import stdin

def mp():
	return map(int, stdin.readline().split())

def ml():
	return list(map(int, stdin.readline().split()))
for _ in range(int(input())):
	n = int(input())
	a = ml()
	ans = []
	for x in a:
		if x not in ans:
			ans.append(x)
	print(*ans)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	seq = [int(i) for i in input().split(' ')]
	seq2 = list()
	for i in seq:
		if i not in seq2:
			seq2.append(i)
	for i in seq2:
		print(i, end=' ')


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	p = [*map(int, input().split())]
	idx = defaultdict(int)
	for i in range(2 * n):
		idx[p[i]] = max(i, idx[p[i]])
	print(*sorted([*range(1, n + 1)], key=lambda x: idx[x]))


t = int(input())
while t:
	t = t - 1
	n = int(input())
	l = [int(i) for i in input().split()]
	s = []
	for i in l:
		if i not in s:
			s.append(i)
	for i in s:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	p = [int(x) for x in input().split()]
	visited = set()
	for i in range(2 * n - 1, -1, -1):
		if p[i] not in visited:
			visited.add(p.pop(i))
	print(' '.join([str(x) for x in p]))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = list(dict.fromkeys(l))
	for i in s:
		print(i, sep=' ', end=' ')
	print()


t = int(input().strip())
for i in range(t):

	def restore_permutation(perm):
		h = [0] * (len(perm) // 2)
		res = []
		for n in perm:
			if not h[n - 1]:
				res.append(n)
				h[n - 1] = 1
		print(*res)
	_ = int(input().strip())
	p = [int(x) for x in input().strip().split()]
	restore_permutation(p)


def permute(A):
	res = []
	s = set()
	for i in A:
		if i not in s:
			s.add(i)
			res.append(i)
	for i in res:
		print(i, ' ', end='')
	print()
t = int(input())
for i in range(t):
	n = int(input())
	n = 2 * n
	A = [int(i) for i in input().split()][:n]
	permute(A)


n = int(input())
for i in range(n):
	t = int(input())
	k = list(map(str, input().split()))
	li = []
	for i in k:
		if i not in li:
			li.append(i)
	for x in li:
		print(x, end=' ')


from collections import OrderedDict
for i in range(int(input())):
	l = []
	s = []
	a = int(input())
	l = list(map(int, input().split()))
	s = list(OrderedDict.fromkeys(l))
	print(*s)


T = int(input())
for _ in range(T):
	n = int(input())
	a = [0] * (n + 1)
	ia = list(map(int, input().split()))
	ans = []
	for i in ia:
		if not a[i]:
			ans.append(i)
			a[i] = 1
	print(' '.join((str(i) for i in ans)))


t = int(input())
for _ in range(t):
	k = int(input())
	nums = [int(i) for i in input().split(' ')]
	n = int(len(nums) / 2)
	a = [False for i in range(n)]
	perm = []
	for i in range(len(nums)):
		if not a[nums[i] - 1]:
			perm.append(nums[i])
			a[nums[i] - 1] = True
	print(*perm, sep=' ')


for ii in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	v = []
	h = {}
	for i in range(len(arr)):
		if len(v) == n:
			break
		elif arr[i] not in h:
			v.append(arr[i])
			h[arr[i]] = 1
		else:
			continue
	for i in range(len(v)):
		print(v[i], end=' ')
	print()


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return i
for i in range(int(input())):
	n = getN()
	arr = getList()
	check = [0] * 100
	ans = []
	for i in range(n * 2):
		if not check[arr[i]]:
			ans.append(arr[i])
			check[arr[i]] += 1
	print(*ans)


t = int(input().split()[0])
for case in range(t):
	ans = []
	n = int(input().split()[0])
	arr = list(map(int, input().split()))
	nums = set()
	for i in range(1, n + 1):
		nums.add(i)
	for i in range(2 * n):
		if arr[i] in nums:
			nums.remove(arr[i])
			ans.append(arr[i])
	print(*ans)


def solve(x, y):
	count = []
	for i in range(2 * x):
		count.append(0)
	for i in range(2 * x):
		if count[y[i]] == 0:
			print(y[i], end=' ')
			count[y[i]] += 1
	print()
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	solve(n, arr)


from __future__ import division, print_function
import itertools, os, sys, threading
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
from random import randrange
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = read()
		ans = []
		sett = set()
		for i in arr:
			if not i in sett:
				ans.append(i)
				sett.add(i)
		print(*ans)
main()


for i in [*open(0)][2::2]:
	print(*dict.fromkeys(map(int, i.split())))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	out = []
	for i in l:
		if i in out:
			continue
		else:
			out.append(i)
	for i in out:
		print(i, end=' ')
	print()


for i in range(int(input())):
	lh = int(input())
	rez = []
	buf = []
	nn = list(map(int, input().split()))
	for j in range(lh * 2):
		x = nn[j]
		if len(buf) == 0:
			rez.append(x)
			buf.append(x)
		elif x == buf[0]:
			buf.pop(0)
		else:
			rez.append(x)
			buf.append(x)
	print(*rez)


t = int(input())
for i in range(t):
	n = int(input())
	vetor = list(map(int, input().split()))
	aux = []
	for a in range(len(vetor)):
		if vetor[a] not in aux:
			aux.append(vetor[a])
			n -= 1
			if n <= 0:
				break
	for b in range(len(aux)):
		print(aux[b], end=' ')
	print()


a = int(input())
for i in range(0, a):
	b = int(input())
	arr = list(map(int, input().split()))
	d = dict()
	ans = []
	for i in arr:
		if i not in ans:
			ans.append(i)
	print(' '.join(map(str, ans)))


def restore(permu):
	ans = []
	for i in permu:
		if i not in ans:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()
t = int(input())
for i in range(t):
	p = int(input())
	permu = list(map(int, input().split()))
	restore(permu)


t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().strip().split()))
	visited = []
	for num in nums:
		if num in visited:
			continue
		visited.append(num)
	print(' '.join((str(el) for el in list(visited))))


t = int(input())
while t > 0:
	n = int(input())
	l = tuple(map(int, input().split()))
	r = []
	for i in l:
		if i not in r:
			r.append(i)
	print(*r)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	s = set()
	res = []
	for i in ar:
		if i not in s:
			res.append(i)
			s.add(i)
	print(*res)


t = int(input())
lst1 = []
for i in range(t):
	n = int(input())
	all = [int(i) for i in input().split()]
	lst = []
	for i in all:
		if i not in lst:
			lst.append(i)
	lst1.append(lst)
for i in lst1:
	for j in i:
		print(j, end=' ')
	print('\n')


import sys
from collections import deque as dq
si = sys.stdin.readline

def main():
	t = int(si())
	while t > 0:
		t -= 1
		n = int(si())
		l = [e for e in si().split()]
		ansSet = set()
		q = dq()
		qs = 0
		for e in l:
			if e not in ansSet:
				ansSet.add(e)
				q.append(e)
				qs += 1
		s = ''
		while qs > 0:
			qs -= 1
			s += q.popleft() + ' '
		print(s)
main()


from sys import stdin, stdout
from sys import maxsize
input = stdin.readline

def solve():
	pass
test = 1
test = int(input().strip())
for t in range(0, test):
	n = int(input().strip())
	a = [int(x) for x in input().strip().split()]
	ans = []
	visited = set()
	for el in a:
		if el not in visited:
			ans += [el]
			visited.add(el)

	def onedarr(a):
		for el in a:
			print(el, end=' ')
		print()
	onedarr(ans)
	ans = solve()


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	s = set()
	ans = []
	for i in range(len(l)):
		if l[i] not in ans:
			ans.append(l[i])
		else:
			continue
	print(' '.join(map(str, ans)))
	t -= 1


T = int(input())
for _ in range(T):
	n = int(input())
	x = list(map(int, input().split()))
	s = set()
	for i in range(len(x)):
		if x[i] not in s:
			print(x[i], end=' ')
		s.add(x[i])
	print()


t = int(input())
while t:
	t -= 1
	try:
		n = int(input())
	except:
		print('', end='')
	l = list(map(int, input().strip().split()))
	s = []
	s.append(l[0])
	for x in l:
		if x in s:
			continue
		else:
			s.append(x)
	for x in s:
		print(x, end=' ')
	print()


pa = input()
p = int(pa)
while p > 0:
	p = p - 1
	n = int(input())
	lst = list()
	na = input()
	lst = na.split()
	op = list()
	for i in range(0, len(lst)):
		lst[i] = int(lst[i])
	for t in range(0, len(lst)):
		if lst[t] in op:
			continue
		else:
			op.append(lst[t])
	print(*op)


for i in range(int(input())):
	n = int(input())
	numbers = list(map(int, input().split()))
	set_numbers = {numbers[0]}
	answer = [numbers[0]]
	for i in range(1, 2 * n):
		if numbers[i] in set_numbers:
			numbers[i] = False
		else:
			set_numbers.add(numbers[i])
			answer.append(numbers[i])
	print(*answer)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	p = []
	for i in a:
		if i not in p:
			p.append(i)
	print(*p)


T = int(input())
for _ in range(T):
	input()
	A = input().split(' ')
	A = list(map(int, A))
	seen = set()
	P = []
	for a in A:
		if a not in seen:
			P += [a]
		seen.add(a)
	print(*P)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	a = []
	c = 0
	while i < len(l):
		if c == n:
			break
		if l[i] not in a:
			a.append(l[i])
			print(l[i], end=' ')
			c += 1
		i += 1
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	d = set()
	q = []
	for i in x:
		if i not in d:
			d.add(i)
			q.append(i)
	print(*q)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	x = [0] * n
	y = []
	for i in range(len(a)):
		if x[a[i] - 1] == 0:
			y.append(a[i])
		x[a[i] - 1] += 1
	print(' '.join(map(str, y)))


t = int(input())
for _ in range(0, t):
	input()
	a = list(map(int, input().split()))
	tmp = []
	for i in range(0, len(a)):
		if a[i] not in tmp:
			tmp.append(a[i])
	answer = str(tmp[0])
	for i in range(1, len(tmp)):
		answer = answer + ' ' + str(tmp[i])
	print(answer)


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = []
	k = 0
	for j in range(2 * n):
		if k == 0 or (k != 0 and A[j] not in B):
			B.append(A[j])
			k += 1
	print(*B)


import math
import os
import random
import re
import sys
import copy
from collections import Counter

def solve():
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().strip().split()))
		c = dict(Counter(l))
		a = []
		c = 0
		for i in range(2 * n):
			if l[i] in a:
				continue
			else:
				a.append(l[i])
				c += 1
			if c == n:
				break
		print(' '.join(map(str, a)))
solve()


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))
ans = 0

def dfs(visited, node, digits, tree):
	if not visited[node]:
		visited[node] = True
		digits += str(node)
		leafNode = True
		for child in tree[node]:
			leafNode = False
			dfs(visited, child, digits, tree)
		if leafNode:
			global ans
			ans += int(digits)

def main():
	n = int(input())
	arr = array()
	m = defaultdict(int)
	ans = []
	for i in range(n * 2):
		if m[arr[i]] == 0:
			ans.append(arr[i])
			m[arr[i]] += 1
	print(*ans)
t = int(input())
for _ in range(t):
	main()


t = int(input())
for i in range(t):
	k = int(input())
	l = list(map(int, input().split()))
	p = []
	for i in l:
		if i not in p:
			p.append(i)
			if len(p) == k:
				break
	print(*p)


T = int(input())
for case in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	ans_list = []
	for i in a:
		if i not in ans_list:
			ans_list.append(i)
	ans_list = map(str, ans_list)
	print(' '.join(ans_list))


def answer(a, n):
	c = [0 for i in range(n)]
	for i in a:
		if c[i - 1] == 0:
			c[i - 1] = 1
			print(i, end=' ')
	print()
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	answer(a, n)


t = int(input())
for test in range(t):
	n = int(input())
	nums = [int(v) for v in input().split()]
	dict = {}
	ans = []
	for i in nums[::-1]:
		if i in dict:
			continue
		else:
			ans.insert(0, i)
			dict[i] = 0
	for i in range(n):
		if i == n - 1:
			print(ans[i])
		else:
			print(ans[i], end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	vis = [False for x in range(n + 1)]
	for i in range(2 * n):
		if not vis[a[i]]:
			vis[a[i]] = True
			ans.append(a[i])
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	for el in a:
		len_before = len(s)
		s.add(el)
		if len(s) > len_before:
			print(el, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	vis = {}
	ans = []
	for i in a:
		if i not in vis:
			vis[i] = True
			ans.append(i)
	print(*ans)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	d = {}
	a = input()
	A = list(map(int, list(a.split())))
	res = []
	for i in range(2 * n - 1, -1, -1):
		if A[i] not in d:
			res.append(A[i])
			d[A[i]] = 1
	ans = res[::-1]
	for i in ans:
		print(i, end=' ')
	print()


def solve(n, arr):
	out = []
	for i in range(2 * n):
		if arr[i] not in out:
			out.append(arr[i])
			if len(out) == n:
				out = map(str, out)
				return ' '.join(out)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(solve(n, arr))


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	val = {}
	ans = []
	for i in lst:
		if i not in val:
			ans.append(i)
			val[i] = 1
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
while t > 0:
	n = int(input())
	_lst = input().split(' ')
	lst = [int(x) for x in _lst]
	p = []
	for val in lst:
		if val not in p:
			p.append(val)
	for x in p:
		print(x, end=' ')
	print()
	t -= 1


t = int(input())
for test in range(t):
	n = int(input())
	a = input()
	a = a.strip()
	a = a.split(' ')
	unique = []
	for i in a:
		if i not in unique:
			unique.append(i)
		if len(unique) == n:
			break
	print(' '.join(unique))


def unique(list1):
	list_set = set(list1)
	unique_list = list(list_set)
	for x in unique_list:
		print(x, end=' ')
t = int(input())
while t > 0:
	n = int(input())
	list1 = list(map(int, input().strip().split()))[:2 * n]
	unique(list1)
	print(end='\n')
	t = t - 1


t = int(input(''))
while t > 0:
	n = int(input(''))
	a = list()
	b = list()
	p = input('')
	q = p.split()
	for i in range(2 * n):
		a.append(int(q[i]))
	for i in range(2 * n):
		if a[i] in b:
			continue
		else:
			b.append(a[i])
	for i in range(n):
		print(b[i], end=' ')
	t = t - 1


import sys
input = sys.stdin.readline
output = sys.stdout.write

def main():
	tests = int(input().rstrip())
	for i in range(tests):
		i = int(input().rstrip())
		list_ = list(map(int, input().rstrip().split()))
		unper = []
		s = 0
		while i > 0:
			num = list_[s]
			if num not in unper:
				unper.append(num)
				i -= 1
			s += 1
		for j in unper:
			output(str(j) + ' ')
		output('\n')
main()


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def DFS(root, g, vis, ans):
	vis[root] = 1
	for c in g[root]:
		if vis[c] == 0:
			ans.append(c)
			DFS(c, g, vis, ans)
MOD = 1000000007
PMOD = 998244353
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	d = {}
	x = []
	for i in range(2 * n):
		if a[i] not in d:
			x.append(a[i])
			d[a[i]] = 1
		else:
			d[a[i]] += 1
	print(*x)


entry_1 = int(input())
for i in range(entry_1):
	length = int(input())
	entry_2 = input().split()
	sol = []
	for t in range(length * 2):
		if entry_2[t] not in sol:
			sol.append(entry_2[t])
		else:
			continue
	print(' '.join(sol))


for _ in range(int(input())):
	n = int(input())
	ll = []
	list1 = list(map(int, input().split()))
	for i in range(2 * n):
		if list1[i] in ll:
			continue
		else:
			ll.append(list1[i])
	print(*ll)


t = int(input())
for i in range(t):
	n = int(input())
	P_mod = [int(s) for s in input().split(' ')]
	P = []
	for j in range(2 * n):
		if P_mod[j] not in P:
			P.append(P_mod[j])
	print(' '.join([str(x) for x in P]))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = []
	seen = set()
	for (i, num) in enumerate(a):
		if num not in seen:
			ans.append(num)
			seen.add(num)
	print(*ans)


from sys import stdin
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = list(dict.fromkeys(arr))
	print(*arr)


n = int(input())
for i in range(0, n):
	a = input()
	ans = []
	a = list(map(int, input().strip().split()))
	for i in a:
		if i not in ans:
			ans.append(i)
	print(*ans)


z = int(input())
for o in range(z):
	n = int(input())
	a = list(map(int, input().split()))
	ans = [a[0]]
	cnt = 1
	for i in range(1, len(a)):
		if cnt == n:
			break
		if a[i] not in ans:
			ans.append(a[i])
			cnt += 1
	for i in range(n):
		print(ans[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	d = {}
	for i in li:
		if i not in d:
			d[i] = 1
	li = []
	for i in d:
		li.append(i)
	print(*li)


t = int(input())
for i in range(t):
	input()
	a = list(map(int, input().split()))
	used = set()
	res = []
	for j in range(len(a)):
		if a[j] in used:
			continue
		else:
			res.append(str(a[j]))
			used.add(a[j])
	print(' '.join(map(str, res)))


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		if i not in d:
			d[i] = 1
	k = d.keys()
	print(*k)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	lst2 = []
	for i in lst:
		if i not in lst2:
			lst2.append(i)
	print(' '.join(map(str, lst2)))


def perm(n):
	l = []
	for i in n:
		if i not in l:
			l.append(i)
	return l
tc = int(input())
for i in range(tc):
	n = int(input())
	nn = list(map(int, input().split()))
	print(*perm(nn))


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(1, n + 1):
		d[i] = 0
	l = []
	for i in range(2 * n):
		if d[a[i]] == 0:
			l.append(a[i])
			d[a[i]] += 1
	print(' '.join(map(str, l)))
	t = t - 1


import sys, math, collections
from collections import defaultdict

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')

def get_array():
	l = list(map(int, input().split()))
	return l

def get_2_ints():
	(a, b) = map(int, input().split())
	return (a, b)

def get_3_ints():
	(a, b, c) = map(int, input().split())
	return (a, b, c)

def sod(n):
	(n, c) = (str(n), 0)
	for i in n:
		c += int(i)
	return c

def getFloor(A, x):
	(left, right) = (0, len(A) - 1)
	floor = -1
	while left <= right:
		mid = (left + right) // 2
		if A[mid] == x:
			return A[mid]
		elif x < A[mid]:
			right = mid - 1
		else:
			floor = A[mid]
			left = mid + 1
	return floor

def main():
	for tt in range(int(input())):
		n = int(input())
		l = get_array()
		c = collections.Counter(l)
		ans = []
		for i in l:
			if c[i]:
				ans.append(i)
				c[i] = c[i] - 2
		print(*ans)
main()


t = int(input())
for test in range(t):
	n = int(input())
	s = input().split()
	ans = ''
	seen = []
	for i in s:
		if i in seen:
			ans += i
			ans += ' '
		else:
			seen.append(i)
	print(ans[:-1])


t = int(input())
for z in range(t):
	n = int(input())
	sequence = input().split()
	newseq = list()
	for y in range(n):
		element = sequence[0]
		newseq.append(element)
		for x in range(2):
			sequence.remove(element)
	for num in newseq:
		print(num, end=' ')
	print()
	newseq.clear()


f = lambda : map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	p = list(f())
	s = list()
	for i in p:
		if i not in s:
			s.append(i)
	print(*s)


from collections import defaultdict
try:
	for _ in range(int(input())):
		n = int(input())
		a = [int(i) for i in input().split()]
		l = []
		for i in a:
			if i not in l:
				l.append(i)
			if len(l) == n:
				break
		print(*l)
except:
	pass


t = int(input(''))
while t != 0:
	size = int(input(''))
	fulllist = input('').split(' ')
	list1 = []
	for i in range(len(fulllist)):
		fulllist[i] = int(fulllist[i])
		if fulllist[i] not in list1:
			list1.append(fulllist[i])
	for i in range(len(list1)):
		print(list1[i], end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	s = set()
	for i in l:
		if i not in s:
			s.add(i)
		else:
			ans.append(i)
	print(' '.join(map(str, ans)))


import math
num_cases = int(input())
for _ in range(num_cases):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	d = {}
	for elem in arr:
		if elem not in d:
			d[elem] = 1
			print(elem, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	for num in a:
		if num not in p:
			p.append(num)
	print(*p)


for _ in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = []
	for i in b:
		if i in c:
			continue
		else:
			c.append(i)
	print(*c)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	(ar1, ar2) = ([], [])
	for i in arr:
		if i in ar1:
			ar2.append(i)
		else:
			ar1.append(i)
	print(*ar1)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l2 = []
	for i in range(len(l)):
		if l.count(l[i]) == 2:
			l2.append(l[i])
			l[i] = 0
	l2 = [str(x) for x in l if x != 0]
	print(' '.join(l2))


T = int(input())
for t in range(T):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	left = []
	right = []
	left.append(a[0])
	li = 0
	for each in a[1:]:
		if len(left) == len(right):
			left.append(each)
		elif li >= len(left):
			left.append(each)
		elif each == left[li]:
			right.append(each)
			li += 1
		else:
			left.append(each)
	print(*left)


t = int(input())
k = [[] for i in range(t)]
for j in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	i = 0
	while i < len(a) - 1:
		if a[i] in a[i + 1:len(a)]:
			k[j].append(a[i])
		i += 1
for i in k:
	print(*i)


t = int(input())
for i in range(t):
	dlina = int(input())
	s = list(map(int, input().split()))
	d = set()
	for i in s:
		if i not in d:
			print(i, end=' ')
			d.add(i)
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = []
	q = []
	for i in a:
		if len(p) == len(q) or i != p[len(q)]:
			p.append(i)
		else:
			q.append(i)
	print(*p)


GI = lambda : int(input())
GIS = lambda : map(int, input().split())
LGIS = lambda : list(GIS())

def main():
	for t in range(GI()):
		n = GI()
		l = [0] * (n + 1)
		res = []
		for x in GIS():
			if not l[x]:
				l[x] = 1
				res.append(x)
		print(' '.join(map(str, res)))
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	c = set()
	for i in a:
		if i not in c:
			b.append(str(i))
		c.add(i)
	print(' '.join(b))


n = int(input())
for i in range(n):
	a = []
	m = int(input())
	arr = map(int, input().split(' '))
	for i in arr:
		if i not in a:
			a.append(i)
	print(' '.join((str(j) for j in a)))


for _ in range(int(input())):
	n = int(input())
	a = [int(__) for __ in input().split()]
	l1 = []
	for i in a:
		if i not in l1:
			l1.append(i)
	print(' '.join([str(___) for ___ in l1]))


T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	temp = set()
	for i in arr:
		if i in temp:
			continue
		res.append(i)
		temp.add(i)
	print(*res)


c = []
for i in range(int(input())):
	input()
	c.append(list(map(str, input().split())))
for elem in c:
	for i in range(len(elem)):
		if elem.count(elem[i]) > 1:
			elem[i] = ' '
	for i in range(len(elem)):
		if elem[i] != ' ' and i != len(elem) - 1:
			print(elem[i], end=' ')
		elif elem[i] != ' ' and i == len(elem) - 1:
			print(elem[i])


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	hashi = dict()
	for i in li:
		if i not in hashi:
			print(i, end=' ')
			hashi[i] = 1
	print()


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	t = []
	for i in s:
		if i not in t:
			t.append(i)
	print(str(t).replace('[', '').replace(']', '').replace(',', ''))


def solve(l, arr):
	res = []
	for i in range(0, len(arr)):
		flag = False
		for j in range(0, i):
			if arr[i] == a[j]:
				flag = True
				break
		if not flag:
			res.append(arr[i])
	print(*res)
t = int(input())
while t != 0:
	n = int(input())
	a = list(map(int, input().split(' ')))
	solve(n, a)
	t -= 1


t = int(input())
for t1 in range(0, t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	ans = []
	for i in l:
		if i not in d:
			d[i] = 1
			ans.append(i)
		d[i] += 1
	print(*ans)


test_case = int(input())
for _ in range(test_case):
	n = int(input())
	p = list(map(int, input().split()))
	for i in range(1, n + 1):
		p.remove(i)
	print(*p)


t = int(input())
for _ in range(t):
	n = int(input())
	p = [int(i) for i in input().split()]
	a = []
	for q in p:
		if q in a:
			continue
		else:
			a.append(q)
	print(*a, sep=' ')


from collections import Counter
for l in range(int(input())):
	a = int(input())
	b = Counter(list(input().split()))
	for k in b.keys():
		print(k, end=' ')
	print('')


t = int(input())
for case in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	Dic = {}
	for i in range(1, n + 1):
		Dic[i] = False
	res = []
	(i, count) = (0, 0)
	while i < 2 * n and count < n:
		if Dic[arr[i]] == False:
			res.append(arr[i])
			Dic[arr[i]] = True
			count += 1
		i += 1
	for i in range(n):
		if i == n - 1:
			print(res[i])
		else:
			print(res[i], end=' ')


t = int(input())
while t > 0:
	n = int(input())
	li = input().split(' ')
	res = []
	for i in li:
		if i not in res:
			res.append(i)
	print(' '.join(res))
	t -= 1


a = int(input())
for i in range(a):
	x = int(input())
	test = input().split()
	yo = ''
	for j in range(x):
		k2 = test[0]
		yo += test[0] + ' '
		k = test.count(test[0])
		for k1 in range(k):
			test.remove(k2)
	print(yo)


t = int(input())
for qi in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	a = []
	for i in range(len(li)):
		if i == 0:
			a.append(li[i])
		else:
			c = 0
			for j in a:
				if j == li[i]:
					c += 1
			if c == 0:
				a.append(li[i])
	print(*a)


ll = lambda : list(map(int, input().split()))
st = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
from collections import *
from math import *
from datetime import datetime
from sys import stdin, stdout
for _ in range(ii()):
	x = ii()
	s = set()
	l = ll()
	ans = []
	for i in l:
		if i not in s:
			s.add(i)
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = []
	cnt = 0
	for i in l:
		if cnt == n:
			break
		if i not in m:
			m.append(i)
			cnt += 1
	print(*m)


n = int(input())
for i in range(n):
	s = int(input())
	s1 = list(map(int, input().split()))
	s2 = set(s1)
	print(*s2)


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	s = set(li)
	ans = []
	for i in li:
		if i in s:
			ans.append(i)
			s.remove(i)
	for i in ans:
		print(i, end=' ')
	print()


T = int(input())
for _ in range(T):
	N = int(input())
	a = list(map(int, input().split()))
	p = []
	for i in range(N):
		(v, a) = (a[0], a[1:])
		p += [v]
		a.remove(v)
	for x in p:
		print(x, end=' ')
	print()


def solution(arr):
	n = []
	s = set()
	for i in arr:
		if i not in s:
			n.append(i)
			s.add(i)
	return n
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	print(*solution(arr))


for _ in range(int(input())):
	n = int(input())
	X = []
	A = [int(_) for _ in input().split()]
	for _ in A:
		if _ not in X:
			X.append(_)
	print(*X)


def read_array():
	x = []
	x1 = []
	x = input()
	x = x.split(' ')
	for r in range(len(x)):
		x1.append(int(x[r]))
	return x1

def organize(x):
	m = []
	for v in x:
		if not str(v) in m:
			m.append(str(v))
	return ' '.join(m)
j = int(input())
res = []
for r in range(j):
	z = input()
	x = read_array()
	x = organize(x)
	res.append(x)
for k in res:
	print(k)


t = int(input())
l = []
for i in range(t):
	b = int(input())
	s = input()
	n = [int(s) for s in s.split()]
	for j in range(len(n)):
		if n[j] not in l:
			l.append(n[j])
	print(' '.join([str(i) for i in l]))
	l = []


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(it) for it in input().split()]
	solution = []
	for it in arr:
		if solution.count(it):
			pass
		else:
			solution.append(it)
	print(*solution, sep=' ')


import sys
import random
from fractions import Fraction
from math import *

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return map(int, tinput())

def fiinput():
	return map(float, tinput())

def rlinput():
	return list(map(int, input().split()))

def trinput():
	return tuple(rinput())

def srlinput():
	return sorted(list(map(int, input().split())))

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	n = iinput()
	q = rlinput()
	res = []
	w = [0 for i in range(2 * n)]
	for i in range(2 * n):
		if not w[q[i]]:
			res.append(q[i])
			w[q[i]] = 1
	print(*res)
for i in range(iinput()):
	main()


for _ in range(int(input())):
	n = int(input())
	k = [0] * 100
	p = []
	l = list(map(int, input().split()))
	for i in range(2 * n):
		if k[l[i]] == 0:
			k[l[i]] = 1
			p.append(l[i])
	print(*p)


t = int(input())
while t > 0:
	n = int(input())
	k = [int(x) for x in input().split(' ')]
	lst = []
	for i in k:
		if i not in lst:
			lst.append(i)
	for i in lst:
		print(i, end=' ')
	t = t - 1


import sys
input = sys.stdin.buffer.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	for i in range(n + n):
		if arr[i] not in ans:
			ans.append(arr[i])
	for i in range(n):
		print(ans[i], end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	p1 = []
	e = input()
	for j in e.split():
		v = int(j)
		if v not in p1:
			p1.append(v)
			print(v, end=' ')
	print('')


t = int(input())
for j in range(t):
	n = int(input())
	a = [int(a) for a in input().split()]
	p = []
	for i in a:
		if i not in p:
			p.append(i)
	for e in range(len(p) - 1):
		print(p[e], end=' ')
	print(p[-1])


import sys
from math import sqrt
input = sys.stdin.readline

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for l in range(t):
		n = inp()
		a = inlist()
		x = []
		rep = [0] * n
		for i in range(2 * n):
			if rep[a[i] - 1] % 2 == 0:
				x.append(a[i])
				rep[a[i] - 1] += 1
		print(*x)
main()


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	dict = {}
	for i in lst:
		if i in dict:
			dict[i] += 1
		else:
			dict[i] = 1
	for i in dict.keys():
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	X = []
	for x in L:
		if x not in X:
			print(x, end=' ')
			X.append(x)
	print()


import sys
import bisect as bi
import math
from collections import defaultdict as dd
input = sys.stdin.readline

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(inin()):
	n = inin()
	l = ain()
	s = set()
	ans = []
	for i in l:
		if i not in s:
			s.add(i)
			ans += [i]
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	L = [int(x) for x in input().split()]
	l = []
	for i in L:
		if i not in l:
			l.append(i)
		else:
			continue
	print(*l)


t = int(input())
for i in range(t):
	n = int(input())
	ans = dict()
	for i in range(n):
		ans[i + 1] = ans.get(i + 1, 0)
	x = list(map(int, input().split()))
	answer = list()
	for i in x:
		if ans[i] == 0:
			answer.append(i)
			ans[i] += 1
		elif ans[i] == 1:
			continue
	for i in answer:
		print(i, end=' ')
	print()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math as mt
from collections import deque, defaultdict

def main():
	for _ in range(ri()):
		n = ri()
		l = ria()
		d = defaultdict(int)
		for i in l:
			d[i] += 1
		print(*list(d.keys()))

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


def readn():
	return int(input())

def readlist():
	return list(map(int, input().split()))

def readnos():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = readlist()
	f = [0] * (n + 1)
	ans = []
	for i in range(len(a)):
		if f[a[i]] != 1:
			ans.append(a[i])
			f[a[i]] = 1
	print(*ans, sep=' ')


t = int(input())
for j in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li_u = []
	for i in range(len(li)):
		if li[i] in li_u:
			pass
		else:
			li_u.append(li[i])
	for x in li_u:
		print(x, end=' ')
	print()


t = int(input())
while t:
	n = int(input())
	a = [int(i) for i in input().split()]
	vis = set()
	p = []
	for ele in a:
		if ele in vis:
			continue
		p.append(ele)
		vis.add(ele)
	for ele in p:
		print(ele, end=' ')
	print()
	t -= 1


t = int(input())
for k in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s = set()
	for i in arr:
		if i not in s:
			print(i, end=' ')
			s.add(i)
	print()


for t in range(int(input())):
	n = int(input())
	s = set()
	a = []
	for x in input().split():
		num = int(x)
		if num in s:
			a.append(num)
		s.add(num)
	for i in a:
		print(i, end=' ')
	print()


from collections import defaultdict
t = int(input())
for q in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	di = defaultdict()
	ans = []
	for i in range(2 * n):
		if li[i] not in di:
			ans.append(str(li[i]))
			di[li[i]] = 1
	print(' '.join(ans))


t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	s = set()
	ans = []
	for i in range(2 * n):
		if arr[i] not in s:
			s.add(arr[i])
			ans.append(arr[i])
	res = ''
	for i in range(len(ans)):
		res += str(ans[i]) + ' '
	print(res[0:len(res) - 1])
	continue


from collections import OrderedDict
for _ in range(int(input())):
	n = int(input())
	arr = list((int(i) for i in input().split()))
	mp = OrderedDict()
	for i in arr:
		mp[i] = mp.get(i, 0)
		mp[i] += 1
	for i in mp:
		print(i, end=' ')


t = int(input())
test_cases = []
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	test_cases.append([n, l])
for i in range(t):
	perm = []
	n = test_cases[i][0]
	check_list = [k for k in range(n)]
	for j in range(2 * n):
		if check_list[test_cases[i][1][j] - 1] != -1:
			perm.append(test_cases[i][1][j])
			check_list[test_cases[i][1][j] - 1] = -1
	ans = ''
	for j in range(n - 1):
		ans += str(perm[j]) + ' '
	ans += str(perm[n - 1])
	print(ans)


import sys
INP = lambda : sys.stdin.readline().strip()
INT = lambda : int(INP())
MAP = lambda : map(int, INP().split())
ARR = lambda : [int(i) for i in INP().split()]

def JOIN(arr, x=' '):
	return x.join([str(i) for i in arr])

def EXIT(x='NO'):
	print(x)
	exit()
for _ in range(INT()):
	n = INT()
	arr = ARR()
	(p, pd) = ([], {})
	for x in arr:
		if x in pd:
			continue
		pd[x] = 0
		p.append(x)
	print(JOIN(p))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	hash_table = [0] * 51
	ans = []
	for i in a:
		if hash_table[i] == 0:
			ans.append(i)
		hash_table[i] += 1
		if len(ans) == n:
			break
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	used = [False] * (n + 1)
	a = list(map(int, input().split()))
	for i in range(2 * n):
		x = a[i]
		if not used[x]:
			used[x] = True
			print(x, end=' ')
	print()


from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in range(2 * n):
		if a[i] in l:
			pass
		else:
			l.append(a[i])
	print(*l)


n = int(input())
seqs = [(input(), map(int, input().split()))[1] for _ in range(n)]
for seq in seqs:
	p = []
	for el in seq:
		if el not in p:
			p.append(el)
	print(*p)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	temp = []
	i = 0
	c = 0
	while c < n:
		if l[i] not in temp:
			temp.append(l[i])
			c += 1
		i += 1
	for i in temp:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	temp = [False] * n
	for var in ar:
		if not temp[var - 1]:
			temp[var - 1] = True
			n -= 1
			print(var, end=' ')
		if n == 0:
			break
	print()


t = int(input())
while t != 0:
	t = t - 1
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	brr = [0] * n
	j = 0
	for i in arr:
		if n == j:
			break
		if i in brr:
			continue
		else:
			brr[j] = i
			j += 1
	for i in brr:
		print(i, end=' ')
	print()


t = int(input())
for j in range(t):
	input()
	r = []
	a = list(input().split())
	for i in a:
		if i not in r:
			r.append(i)
	print(' '.join(r))


t = int(input())
for test in range(t):
	n = int(input())
	n = 2 * n
	a = list(map(int, input().strip().split()))[:n]
	lst = []
	for i in a:
		if i not in lst:
			lst.append(i)
	for i in lst:
		print(i, end=' ')


for _ in range(int(input())):
	n = int(input())
	nums = []
	arr = [int(x) for x in input().split()]
	for i in arr:
		if i not in nums:
			nums.append(i)
	for i in nums:
		print(i, end=' ')
	print()


testcase = int(input())
for _ in range(0, testcase):
	n = int(input())
	arr = list(map(int, input().split()))
	seen = set()
	print(*[x for x in arr if not (x in seen or seen.add(x))])


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = set(a)
	print(*s)


def per(m, arr):
	li = []
	l = [i for i in range(1, m + 1)]
	for i in arr:
		if i not in li:
			li.append(i)
	print(*li, sep=' ')
n = int(input())
for i in range(n):
	m = int(input())
	arr = list(map(int, input().split()))
	per(m, arr)


def main():
	for _ in range(int(input())):
		en = int(input())
		aa = list((int(ex) for ex in input().split()))
		yes = list()
		for ai in aa:
			if ai not in yes:
				yes.append(ai)
				print(ai, end=' ')
		print()
main()


from collections import defaultdict
T = int(input())
for test in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	count = defaultdict(int)
	ans = []
	for i in range(n * 2):
		if count[a[i]] < a.count(a[i]) // 2:
			ans.append(a[i])
			count[a[i]] += 1
	print(' '.join([str(x) for x in ans]))


import sys
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, sys.stdin.readline().split()))
	s = set()
	ans = []
	for x in arr:
		if x not in s:
			s.add(x)
			ans.append(x)
	for x in ans:
		print(x, end=' ')
	print('')


import math
for i in range(int(input())):
	input()
	a = [int(j) for j in input().split()]
	ans = [a[0]]
	for j in range(len(a)):
		if a[j] not in ans:
			ans.append(a[j])
	for j in ans:
		print(j, end=' ')
	print()


t = int(input())
for m in range(t):
	n = int(input())
	li = list()
	s = input()
	for i in s.split():
		li.append(i)
	dic = dict()
	for k in li:
		if k in dic:
			dic[k] += 1
		else:
			print(k, end=' ')
			dic[k] = dic.get(k, 0) + 1
	print()
exit()


t = int(input())
for i in range(t):
	n = int(input())
	seq = list(map(int, input().split()))
	perm = [seq[0]]
	done = 0
	for x in seq[1:]:
		if len(perm) > done and x == perm[done]:
			done += 1
		else:
			perm.append(x)
	for l in perm:
		print(l, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	z = list((int(num) for num in input().split()))
	oa = []
	for x in range(0, len(z)):
		if not z[x] in oa:
			oa.append(z[x])
		if len(oa) == n:
			break
	print(*oa)


n = int(input())
while n:
	m = int(input())
	arr = list(map(int, input().split()))
	new = []
	for i in arr:
		if i not in new:
			new.append(i)
	print(*new)
	n -= 1


from collections import deque
for i in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	sett = deque()
	for i in ar:
		if i not in sett:
			sett.append(i)
	print(*sett)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		n = N()
		arr = RLL()
		rec = [0] * 100
		res = []
		for i in arr:
			if rec[i] == 0:
				res.append(i)
				rec[i] = 1
		print(*res)
main()


numberOfTc = int(input())
for ctr in range(1, numberOfTc + 1):
	N = int(input())
	permu = list(map(int, input().split()))
	newList = []
	for val in permu:
		if val not in newList:
			print(val, end=' ')
		newList.append(val)
	print()


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	used = set()
	permutation = []
	for e in arr:
		if e not in used:
			permutation.append(e)
			used.add(e)
	for e in permutation:
		print(e, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = dict()
	newl = []
	for i in range(2 * n):
		if l[i] in d:
			pass
		else:
			newl.append(l[i])
			d[l[i]] = 1
	print(*newl)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	final = []
	for j in arr:
		if j not in final:
			final.append(j)
	print(*final, sep=' ')


t = int(input())
for i in range(t):
	a = int(input())
	l = list(map(int, input().split()))
	rs = []
	frec = []
	for o in range(a * 2 + 1):
		frec.append(0)
	for k in range(1, a * 2 + 1):
		n = l[k - 1]
		if frec[n] == 0:
			rs.append(n)
		frec[n] += 1
	for j in range(a):
		print(rs[j])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = [False] * (n + 1)
	ans = []
	for i in range(2 * n):
		if not s[a[i]]:
			ans.append(a[i])
			s[a[i]] = True
	for i in ans:
		print(i, end=' ')
	print()


testcases = int(input())

def Print(arr):
	for i in range(len(arr)):
		print(arr[i], ' ')
for i in range(testcases):
	n = int(input())
	entry_string = input()
	arr = []
	counter = 0
	for j in range(2 * n):
		flag = True
		if j != 2 * n - 1:
			if entry_string[counter + 1] != ' ':
				entry = int(entry_string[counter] + entry_string[counter + 1])
				counter += 3
			else:
				entry = int(entry_string[counter])
				counter += 2
		else:
			entry = int(entry_string[counter])
		for k in range(len(arr)):
			if entry == arr[k]:
				flag = False
		if flag:
			arr.append(entry)
	Print(arr)


a = int(input())
for i in range(a):
	n = int(input())
	num = list(map(int, input().split()))
	itog = []
	m = 0
	for j in range(n * 2 - 1):
		if itog.count(num[0]) == 0:
			itog.append(num[0])
			num.pop(0)
		else:
			num.pop(0)
	print(*itog)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	temp = []
	for i in l:
		if i not in set(temp):
			temp.append(i)
	for i in temp:
		print(i, end=' ')


def main():
	t = int(input())
	for i in range(t):
		n = input()
		p = list(map(int, input().split()))
		resultado = []
		for i in p:
			if i not in resultado:
				resultado.append(i)
		print(*resultado)
main()


from sys import stdin
input = stdin.readline
t = int(input())
while t > 0:
	n = int(input())
	p = list(map(int, input().split()))
	res = []
	s = set()
	for num in p:
		if not s.__contains__(num):
			res.append(num)
			s.add(num)
	for num in res:
		print(num, end=' ')
	print()
	t -= 1


x = input()
x = int(x)
i = 0
j = 0
while i < x:
	a = []
	n = int(input())
	j = 0
	while j < 1:
		m = [int(m) for m in input().split()]
		for n in m:
			if int(n) not in a:
				a.append(n)
			else:
				continue
		j += 1
	print(*a, sep=' ')
	i += 1


def process():
	n = int(input())
	arr = list(map(int, input().split()))
	retlist = []
	se = set()
	for i in arr:
		if i in se:
			continue
		se.add(i)
		retlist.append(i)
	print(*retlist)
for i in range(int(input())):
	process()


import sys, math, cmath, time
start_time = time.time()

def solve():
	n = inp()
	a = inlt()
	q = []
	for i in range(len(a)):
		if a[i] not in q:
			q.append(a[i])
	print(*q)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = (q[ord(a[i]) - 97], 1)
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	used = [False] * 2 * n
	for i in a:
		if used[i] == False:
			ans.append(i)
			used[i] = True
	print(*ans)


for tt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	stack = []
	for item in a:
		if item not in stack:
			stack.append(item)
	print(*stack)


cnt = int(input())
for _ in range(cnt):
	leng = int(input())
	arr = list(map(int, input().split()))
	print(*sorted(set(arr), key=arr.index))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	occured = set()
	out = []
	for elem in a:
		if elem not in occured:
			out.append(elem)
			occured.add(elem)
	print(' '.join(map(str, out)))


T = int(input())
while T:
	n = int(input())
	A = list(map(int, input().split()))
	D = {}
	X = []
	for i in A:
		if i not in D:
			D[i] = 1
			X.append(i)
	print(*X)
	T = T - 1


t = int(input())

def solve():
	temp = []
	n = int(input())
	l = list(map(int, input().split()))
	for i in l:
		if i not in temp:
			temp.append(i)
	for j in temp:
		print(j, end=' ')
	print()
for __ in range(t):
	solve()


t = int(input())
while t:
	n = int(input())
	li = list(map(int, input().split()))
	ans = []
	for i in li:
		if str(i) not in ans:
			ans.append(str(i))
	print(' '.join(ans))
	t -= 1


def num():
	return int(input())

def line():
	return map(int, input().split())

def ans(lst):
	return ' '.join(map(str, lst))
from itertools import repeat
t = num()
for _ in repeat(None, t):
	n = num()
	a = iter(line())
	q = [next(a)]
	i = 0
	for x in a:
		if i == len(q) or x != q[i]:
			q.append(x)
		else:
			i += 1
	print(ans(q))


for _ in range(int(input())):
	n = int(input())
	s = set()
	a = []
	b = list(map(int, input().split(' ')))
	for i in b:
		if i not in s:
			s.add(i)
			a.append(i)
	for i in a:
		print(i, end=' ')
	print('')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	for i in a:
		if ans.count(i) == 0:
			ans.append(i)
	print(*ans)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(sys.stdin.readline())
	list_num = list(map(int, sys.stdin.readline().split()))
	count = n
	list_check = [0] * (n + 1)
	list_res = [0] * n
	list_check[list_num[-1]] = 1
	list_res[-1] = list_num[-1]
	for num in list_num:
		if not list_check[num]:
			list_check[num] = 1
			list_res[n - count] = num
			count -= 1
		if not count:
			break
	print(*list_res)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	print(*list(set([int(x) for x in input().split()])))


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	check = [False for i in range(n + 1)]
	st = []
	temp = []
	for i in l:
		if not check[i]:
			check[i] = True
			temp.append(i)
		else:
			st += temp
			temp = []
	for i in st:
		print(i, end=' ')
	print()
t = int(input())
while t:
	t -= 1
	solve()


t = int(input())
for p in range(t):
	n = int(input())
	ara = list(map(int, input().strip().split()))
	freq = [0] * (2 * n)
	ans = list()
	for i in range(2 * n):
		if freq[ara[i]] == 0:
			ans.append(ara[i])
		freq[ara[i]] += 1
	print(*ans, sep=' ')


T = int(input())
while T:
	N = int(input())
	arr = list(map(int, input().split()))
	s = set()
	for i in range(len(arr)):
		if arr[i] not in s:
			s.add(arr[i])
			print(arr[i], end=' ')
	print()
	T -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	new = []
	arr = list(map(int, input().split()))
	for i in range(n):
		for j in arr:
			if len(new) == n:
				break
			if j not in new:
				new.append(j)
	for f in new:
		print(f, end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	soln = []
	arr_set = set()
	for i in arr:
		if i not in arr_set:
			soln.append(i)
			arr_set.add(i)
	print(*soln)


for x in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	l = []
	for i in x:
		if i not in l:
			l.append(i)
	for z in l:
		print(z, end=' ')


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	vis = [0] * (n + 1)
	for i in range(len(ar)):
		if vis[ar[i]] == 0:
			print(ar[i], end=' ')
			vis[ar[i]] = 1
	print()


test = int(input())
for x in range(test):
	num = input()
	numbers = [int(x) for x in input().split()]
	numbers = list(dict.fromkeys(numbers))
	print(*numbers, sep=' ')


def restorer(n, list):
	new_list = []
	for i in list:
		if i not in new_list:
			new_list.append(i)
		if len(new_list) == n:
			return new_list
n = int(input())
list_of_testcases = []
for i in range(n):
	a = int(input())
	b = input().split(' ')
	b = list(map(int, b))
	list_of_testcases.append([a, b])
for test in list_of_testcases:
	length = test[0]
	seq = test[1]
	answers = restorer(length, seq)
	if test != list_of_testcases[-1]:
		for answer in answers:
			print(answer, end=' ')
		print(' ')
	else:
		for answer in answers:
			print(answer, end=' ')


from collections import OrderedDict
t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l = list(OrderedDict.fromkeys(l))
	for i in l:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	length = int(input())
	arr = list(map(int, input().split()))
	out = []
	b = [0] * (length + 1)
	for i in arr:
		if b[i] == 0:
			out.append(i)
			b[i] = 1
	print(*out)


def permutation(values):
	a = []
	for i in range(len(values)):
		if values[i] not in a:
			a.append(values[i])
	return a
t = int(input())
for i in range(t):
	n = int(input())
	values = list(map(int, input().split()))
	print(*permutation(values))


from math import log2, ceil, floor
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	s = []
	for i in range(2 * n):
		if a[i] not in d:
			d[a[i]] = 1
			s.append(a[i])
	print(*s)


cases = int(input())
for case in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	seen = set()
	ret = []
	for i in a:
		if i not in seen:
			seen.add(i)
			ret.append(i)
		if len(ret) == n:
			print(' '.join([str(c) for c in ret]))
			break


t = int(input())
result = []
for i in range(t):
	n = int(input())
	tab = input().split(' ')
	test = []
	for j in tab:
		if j not in test:
			test.append(j)
	result.append(' '.join(test))
for i in result:
	print(i)


for _ in range(int(input())):
	int(input())
	s = []
	for i in map(int, input().split()):
		if i not in s:
			s.append(i)
	print(*s)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [0] * (2 * n)
	arr = input().split()
	ans = [0] * n
	ans[0] = arr[0]
	counter = 1
	for j in range(2 * n):
		if arr[j] not in ans:
			ans[counter] = arr[j]
			counter = counter + 1
	for j in range(n):
		print(ans[j], ' ', end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	h = {}
	for i in input().split():
		h[i] = h.get(i, 0) + 1
	for i in h:
		print(i, end=' ')
	print()


t = int(input())
for case in range(t):
	lenth = int(input())
	lenth *= 2
	a = list(map(int, input().split()))
	b = []
	while lenth > 0:
		b.append(a[0])
		temp = a[0]
		a.remove(temp)
		a.remove(temp)
		lenth -= 2
	for i in b:
		print(i, end=' ')
	print()


T = int(input())
for t in range(T):
	n = int(input())
	s = [int(x) for x in input().split()]
	s = list(set(s))
	print(*s)


def lis(arr):
	stack = [arr[0]]
	for i in range(1, len(arr)):
		if arr[i] not in stack:
			stack.append(arr[i])
	return stack
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(*lis(arr))


import collections
for i in range(int(input())):
	n = int(input())
	permutation = list(map(int, input().split()))
	count = collections.defaultdict(int)
	answer = []
	for num in permutation:
		if count[num] == 0:
			answer.append(num)
		count[num] += 1
	for j in range(n):
		print(answer[j], end=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	h = []
	for _ in range(102):
		h.append(0)
	for i in range(2 * n):
		if h[a[i]] == 0:
			print(a[i], end=' ')
			h[a[i]] += 1
	print()


def solve(n):
	ans = []
	return ans
t = int(input())
for ___ in range(t):
	n = int(input())
	a = [False] * (n + 1)
	inp_str = input()
	inp_split = (int(k) for k in inp_str.split(' '))
	ans = []
	for i in inp_split:
		if a[i] == False:
			a[i] = True
		else:
			ans.append(str(i))
			a[i] = False
	print(' '.join(ans))


for _ in range(int(input())):
	n = int(input())
	list1 = [int(i) for i in input().split()]
	list2 = []
	list3 = []
	for i in range(2 * n):
		for j in range(len(list2)):
			if list2[j] == list1[i]:
				list3.append(list1[i])
				del list2[j]
				break
		list2.append(list1[i])
	print(*list3)


import os
import sys
import time
from io import BytesIO, IOBase

def localInput():
	sys.stdin = open('inputf.in', 'r')
	sys.stdout = open('outputf.in', 'w')
	sys.stderr = open('error.txt', 'w')

def print_to_stderr(*a):
	print(*a, file=sys.stderr)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def solve():
	n = int(input())
	arr = [int(a) for a in input().strip().split(' ')]
	list1 = []
	for numbers in arr:
		if numbers not in list1:
			list1.append(numbers)
	print(*list1)

def main():
	test_cases = int(input())
	for test_units in range(test_cases):
		solve()
execution_time_start = time.clock()
main()
execution_time_stop = time.clock()
print_to_stderr('Total Time Taken: %f Seconds!' % (execution_time_stop - execution_time_start))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	sf = []
	i = 0
	while i < 2 * n:
		if a[i] not in sf:
			sf.append(a[i])
		i += 1
	ans = ''
	i = 0
	while i < n:
		ans += str(sf[i]) + ' '
		i += 1
	print(ans.rstrip())


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	ans = []
	for i in range(len(arr)):
		if d.get(arr[i], -1) == -1:
			print(arr[i], end=' ')
			d[arr[i]] = 1
	print()
	t -= 1


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	lst = list(map(int, input().split()))
	lst1 = [lst[0]]
	for i in range(1, 2 * n):
		x = lst[i]
		if x not in lst1:
			lst1.append(x)
	for i in range(len(lst1)):
		print(lst1[i], end=' ')


test = int(input())
for t in range(test):
	n = int(input())
	lst1 = list(map(int, input().split()))
	lst2 = list()
	for x in lst1:
		if x not in lst2:
			lst2.append(x)
	for y in lst2:
		print(y, end=' ')
	print()


for _ in range(int(input())):
	num = int(input())
	a = list(map(int, input().split()))
	di = {}
	ans = []
	for i in a:
		if i not in di:
			di[i] = 1
			ans.append(i)
	print(*ans)


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	d = set()
	for j in a:
		if j in d:
			l.append(j)
		else:
			d.add(j)
	print(*l)


Q = int(input())
for q in range(Q):
	n = int(input())
	L = list(map(int, input().split()))
	C = [0 for i in range(n * 2 + 1)]
	ans = []
	for i in range(len(L)):
		if C[L[i]] == 0:
			C[L[i]] = 1
			ans.append(L[i])
	print(*ans)


for i in range(int(input())):
	(n, res) = (int(input()), list(map(int, input().split(' '))))
	per = []
	for each in res:
		if not each in per:
			per.append(each)
	print(' '.join((str(x) for x in per)))


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	n = int(inp())
	a = [int(x) for x in inp().split()]
	x = set()
	ans = []
	for i in a:
		if i not in x:
			x.add(i)
			ans.append(i)
	print(*ans)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	p1 = [l[0]]
	p2 = []
	for i in l:
		if i not in p1:
			p1.append(i)
		else:
			p2.append(i)
	print(' '.join(map(str, p1)))
	t -= 1


t = int(input())
myset = set()
lst3 = []
for i in range(t):
	myset = set()
	lst = []
	n = int(input())
	lst2 = list([int(q) for q in input().split()])
	for j in lst2:
		if j in myset:
			continue
		else:
			lst.append(j)
			myset.add(j)
		if len(lst) == n:
			break
	lst3.extend([lst])
for i in lst3:
	print(' '.join((str(n) for n in i)))


for z in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	dir = {}
	ans = []
	for i in range(1, n + 1):
		dir[i] = 0
	for i in range(0, 2 * n):
		if dir[a[i]] == 0:
			ans.append(a[i])
			dir[a[i]] = 1
	print(*ans)


for t in range(int(input())):
	n = int(input())
	a = [None] * n
	for x in input().split():
		num = int(x)
		if a[num - 1] == None:
			print(num, end=' ')
		a[num - 1] = num
	print()


from sys import stdin, stdout, setrecursionlimit
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm, accumulate
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
setrecursionlimit(10 ** 9)
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return input()

def num():
	return int(input())

def L():
	return list(sp())

def LF():
	return list(spf())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def spf():
	return map(int, input.readline().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def pmat2(A):
	for ele in A:
		for j in ele:
			print(j, end='')
		print()

def iseven(n):
	return n % 2 == 0

def seive(r):
	prime = [1 for i in range(r + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(r + 1):
		if prime[i]:
			for j in range(2 * i, r + 1, i):
				prime[j] = 0
	return prime
for _ in range(int(input())):
	n = int(input())
	a = L()
	ans = set()
	for x in a:
		if x not in ans:
			print(x, end=' ')
			ans.add(x)
	print()
endtime = time.time()


import math
LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
SI = lambda : input()
II = lambda : int(input())
t = II()
for q in range(t):
	n = II()
	a = LI()
	ans = []
	d = [0] * (n + 1)
	for i in a:
		if d[i] == 0:
			d[i] = 1
			ans.append(i)
	print(*ans)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	p = [0] * n
	s = [0] * 51
	j = 1
	p[0] = a[0]
	s[a[0]] = 1
	for i in range(2 * n):
		if s[a[i]] != 1:
			p[j] = a[i]
			j = j + 1
			s[a[i]] = 1
	for i in range(n):
		print(p[i], end=' ')
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	l = [int(j) for j in input().split()]
	unique = []
	for i in l:
		if i not in unique:
			unique.append(i)
	print(*unique)


def solve(n, a):
	bool_a = [False] * n
	p = []
	for i in range(len(a)):
		if bool_a[a[i] - 1] == False:
			bool_a[a[i] - 1] = True
			p.append(a[i])
	return p
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	p = solve(n, a)
	print(*p)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	for i in arr:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	t = len(d)
	for i in d:
		print(i, end=' ')
	print()


cases = eval(input())
for _ in range(cases):
	extra = input()
	second = []
	final = []
	start = 1
	list = input().split()
	for num in range(1, 51):
		if str(num) in list:
			second.append(str(num))
		else:
			break
	for element in list:
		if str(element) in second and str(element) not in final:
			final.append(str(element))
		if len(final) == len(second):
			break
	print(' '.join(final))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [] * n
	c = [0] * n
	for i in range(2 * n):
		if c[a[i] - 1] == 0:
			b.append(a[i])
			c[a[i] - 1] = 1
		else:
			continue
	[print(i, end=' ') for i in b]
	print()


for testcase in range(int(input())):
	n = int(input())
	has = [False] * (n + 1)
	for i in map(int, input().split()):
		if has[i]:
			continue
		print(i, end=' ')
		has[i] = True
	print()


t = int(input())
for rep in range(0, t):
	n = int(input())
	arr = list(map(int, input().split()))
	lst = []
	for x in arr:
		if x not in lst:
			lst.append(x)
	for i in range(0, n):
		print(lst[i], end=' ')
	print()


t = int(input())
for m in range(t):
	n = int(input())
	s = input().split()
	lst = []
	lst.append(int(s[0]))
	for i in range(1, 2 * n):
		for j in lst:
			if int(s[i]) == j:
				break
		else:
			lst.append(int(s[i]))
	for i in lst:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l1 = []
	for i in range(len(l)):
		if l[i] in l1:
			pass
		else:
			l1.append(l[i])
	print(*l1)


def read():
	return [int(xx) for xx in input().split()]
(ca,) = read()
for _ in range(ca):
	(__,) = read()
	x = read()
	r = []
	for v in x:
		if v not in r:
			r.append(v)
	print(' '.join((str(o) for o in r)))


t = int(input())
for i in range(t):
	input()
	l = input().split()
	h = set()
	for j in l:
		if j not in h:
			print(j, end=' ')
			h.add(j)
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	ll = []
	for i in range(2 * n):
		if l[i] not in d:
			d[l[i]] = 1
			ll.append(l[i])
	print(*ll)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	output = []
	for i in a:
		if i in output:
			continue
		else:
			output.append(i)
	print(*output)


a = int(input())
arr = []
for i in range(a):
	b = int(input())
	c = [int(i) for i in str(input()).split()]
	d = list(dict.fromkeys(c))
	arr.append(d)
for i in arr:
	for o in i:
		print(o, end=' ')
	print('')


T = int(input())
for i in range(T):
	n = int(input())
	arr = [int(i) for i in input().split()]
	newarr = []
	for j in arr:
		if j not in newarr:
			newarr.append(j)
	print(*newarr, sep=' ')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = l.copy()
	ans = []
	while True:
		a = c[0]
		c = c[1:]
		c.remove(a)
		print(a, end=' ')
		if len(c) == 0:
			break
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	vis = set()
	arr = list(map(int, input().split()))
	ans = []
	for i in arr:
		if i in vis:
			continue
		vis.add(i)
		ans.append(i)
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(str, input().split()))
	u = []
	for ch in s:
		if ch not in u:
			u.append(ch)
	print(' '.join(u))


t = int(input())
for i in range(t):
	length = input()
	inp = input()
	inp_split = inp.split(' ')
	numbers = [int(num) for num in inp_split]
	check = []
	for i in numbers:
		if i not in check:
			check.append(i)
	final1 = [str(i) for i in check]
	final = ' '.join(final1)
	print(final)


t = int(input())
i = 0
while i < t:
	n = int(input())
	a = list(map(int, input().split()))
	index = 2 * n - 1
	b = []
	c = []
	j = 1
	while index > -1:
		if a[index] not in c:
			b.insert(0, a[index])
			c.append(a[index])
		index -= 1
	answer = ''
	for l in b:
		answer += str(l) + ' '
	print(answer)
	i += 1


def per(arr):
	l = []
	for i in arr:
		if i not in l:
			l.append(i)
		else:
			pass
	print(*l, sep=' ')
n = int(input())
for i in range(n):
	p = input()
	arr = list(map(int, input().split()))
	per(arr)


test = int(input())
result = []
for t in range(test):
	length = int(input())
	p = [int(num) for num in input().split()]
	answer = []
	for l in range(2 * length):
		if p[l] not in answer:
			answer.append(p[l])
	result.append(answer)
for count in range(test):
	print(*result[count])


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		a = inlist()
		found = [False] * (n + 1)
		for i in a:
			if found[i] == False:
				print(i, end=' ')
				found[i] = True
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	a = []
	for i in R():
		if i not in a:
			a += (i,)
	print(*a)


def main():
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		res = []
		for i in l:
			if i not in res:
				res.append(i)
		for i in res:
			print(i, end=' ')
main()


n = int(input())
for i in range(n):
	b = []
	a = int(input())
	arr = list(map(int, input().split()))
	for k in arr:
		if k not in b:
			print(k, end=' ')
			b.append(k)
	print()


testcases = int(input())
for i in range(testcases):
	n = int(input())
	arr = list(map(int, input().split()))
	freq_arr = [1] * (n + 1)
	for ele in arr:
		if freq_arr[ele] == 1:
			print(ele, end=' ')
			freq_arr[ele] = 0
	print()


t = int(input())
for q in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lis = [0] * (max(arr) + 1)
	for i in range(len(arr)):
		lis[arr[i]] += 1
	ans = []
	for i in range(len(lis)):
		lis[i] //= 2
	for i in range(len(arr)):
		if lis[arr[i]] == 1:
			ans.append(arr[i])
			lis[arr[i]] = 0
	for i in ans:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	d = {}
	ans = []
	for i in arr:
		d[i] = d.get(i, 0) + 1
		if d[i] == 1:
			ans.append(i)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	seen = [False] * n
	for x in map(int, input().split()):
		if not seen[x - 1]:
			print(x, end=' ')
		seen[x - 1] = True
	print()


numtestcases = int(input())
inputs = []
for a in range(numtestcases):
	thelen = int(input())
	the_input = str(input())
	inputs.append(the_input)
for b in inputs:
	b1 = b.split(' ')
	b2 = []
	for c in b1:
		if c in b2:
			continue
		else:
			b2.append(c)
	the_string = ''
	for the in b2:
		the_string = the_string + the + ' '
	print(the_string[0:len(the_string) - 1])


def read_list():
	return list(map(int, input().split(' ')))

def print_list(l):
	print(' '.join(map(str, l)))
N = int(input())
for _ in range(N):
	n = int(input())
	a = read_list()
	dic = {}
	res = []
	for i in a:
		if i not in dic:
			res.append(i)
			dic[i] = 1
	print_list(res)


import sys
import heapq as hq
from heapq import heappop, heappush
from collections import deque, defaultdict

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def subset_sum_count(arr, n, sum):
	dp = [[0 for _ in range(sum + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				dp[i][j] = 1
			elif arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j - arr[i - 1]] + dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[n][sum]

def prefix(a):
	pre = []
	pre.append(a[0])
	for i in range(1, len(a)):
		pre.append(pre[i - 1] + a[i])
	return pre

def binary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		mi = lo + (hi - lo) / 2
		if func(mi):
			hi = mi
		else:
			lo = mi
	return (lo + hi) / 2

def ternary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		lo_third = lo + (hi - lo) / 3
		hi_third = hi - (hi - lo) / 3
		if func(lo_third) < func(hi_third):
			lo = lo_third
		else:
			hi = hi_third
	return (lo + hi) / 2

def discrete_binary_search(func, lo, hi):
	while lo < hi:
		mi = lo + (hi - lo) // 2
		if func(mi):
			hi = mi
		else:
			lo = mi + 1
	return lo

def discrete_ternary_search(func, lo, hi):
	while lo <= hi:
		lo_third = lo + (hi - lo) // 3
		hi_third = lo + (hi - lo) // 3 + (1 if 0 < hi - lo < 3 else (hi - lo) // 3)
		if func(lo_third) < func(hi_third):
			lo = lo_third + 1
		else:
			hi = hi_third - 1
	return lo

def right_rotate(a, s):
	return a[s:] + a[:s]

def dec_to_bin(x):
	return int(bin(x)[2:])

def str_to_integer_list(n):
	a = []
	for i in range(len(n)):
		a.append(int(n[i]))
	return a

def list_to_str(l):
	s = ''
	for i in l:
		s += str(i)
	return s

def dijkstra(s, N, E):
	visited = set()
	dist = {}
	for i in range(1, N + 1):
		dist[i] = 1 << 29
	queue = [(dist[i], i) for i in range(1, N + 1)]
	hq.heappush(queue, (0, s))
	dist[s] = 0
	while queue:
		(d, u) = hq.heappop(queue)
		if u in visited:
			continue
		for t in E[u]:
			(v, r) = t
			if dist[v] > d + r:
				dist[v] = d + r
				hq.heappush(queue, (dist[v], v))
		visited.add(u)
	return dist

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def dijkstra(n, graph, start):
	(dist, parents) = ([float('inf')] * n, [-1] * n)
	dist[start] = 0
	queue = [(0, start)]
	while queue:
		(path_len, v) = heappop(queue)
		if path_len == dist[v]:
			for (w, edge_len) in graph[v]:
				if edge_len + path_len < dist[w]:
					(dist[w], parents[w]) = (edge_len + path_len, v)
					heappush(queue, (edge_len + path_len, w))
	return (dist, parents)

def path(start, end, parent):
	path = [end]
	while path[-1] != start:
		path.append(parent[path[-1]])
	path.reverse()
	return path

def bfs(graph, start, goal):
	if start == goal:
		return [start]
	visited = {start}
	queue = deque([(start, [])])
	while queue:
		(current, path) = queue.popleft()
		visited.add(current)
		for neighbor in graph[current]:
			if neighbor == goal:
				return path + [current, neighbor]
			if neighbor in visited:
				continue
			queue.append((neighbor, path + [current]))
			visited.add(neighbor)
	return None
import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = inp()
		a = inlt()
		res = []
		for i in a:
			if i not in res:
				res.append(i)
		print(*res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import bisect as bi
import math as mt
import collections as cc
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	n *= 2
	l = I()
	s = set()
	ans = []
	for i in range(n):
		if l[i] not in s:
			ans.append(l[i])
			s.add(l[i])
	print(*ans)


rr = input
rri = lambda : int(rr())
rrm = lambda : list(map(int, rr().split()))

def solve(A):
	ans = []
	i = 0
	for a in A:
		if i == len(ans) or a != ans[i]:
			ans.append(a)
		else:
			i += 1
	return ' '.join(list(map(str, ans)))
T = rri()
for i in range(1, T + 1):
	n = rri()
	A = rrm()
	ans = solve(A)
	print(ans)


def unique(list1):
	unique_list = []
	for x in list1:
		if x not in unique_list:
			unique_list.append(x)
	print(('{} ' * len(unique_list)).format(*unique_list))
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	unique(a)


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	result = []
	seen = set()
	for elem in arr:
		if elem not in seen:
			seen.add(elem)
			result.append(elem)
	print(*result)


def Remove(duplicate):
	final_list = []
	for num in duplicate:
		if num not in final_list:
			final_list.append(num)
	return final_list
x = int(input())
for i in range(x):
	n = int(input())
	ar = list(map(int, input().split()))[:4 * n]
	d = Remove(ar)
	print(*d)


t = int(input())
while t != 0:
	n = int(input())
	a = [int(i) for i in input().split()]
	for i in range(0, len(a)):
		if a[i] != 0:
			print(a[i], end=' ')
			for j in range(i + 1, len(a)):
				if a[i] == a[j]:
					a[j] = 0
	print()
	t -= 1


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	arr = [int(i) for i in input().split()]
	ans = []
	s = set()
	for i in arr:
		if i not in s:
			ans.append(i)
			s.add(i)
	for i in ans:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input()) * 2
	a = list(map(int, input().split()))
	p = []
	for i in range(n):
		if a[i] not in p:
			for j in range(i + 1, n):
				if a[j] == a[i]:
					p.append(a[i])
	print(*p)


import sys

def readlines(type=int):
	return list(map(type, sys.stdin.readline().split()))

def read(type=int):
	return type(sys.stdin.readline().strip())
joint = lambda it, sep=' ': sep.join([str(i) if type(i) != list else sep.join(map(str, i)) for i in it])

def solve(l, nums):
	result = list()
	rset = set()
	for num in nums:
		if num not in rset:
			rset.add(num)
			result.append(num)
	return joint(result)

def main():
	n = read()
	results = []
	for _ in range(n):
		l = read()
		nums = readlines()
		results.append(solve(l, nums))
	print(joint(results, '\n'))
main()


import time
from collections import deque

def inpt():
	return int(input())

def inpl():
	return list(map(int, input().split()))

def inpm():
	return map(int, input().split())

def solve():
	n = inpt()
	l = inpl()
	d = {}
	ans = []
	for i in l:
		if i not in d:
			d[i] = 1
			ans.append(i)
		if len(d) == n:
			break
	print(*ans)

def main():
	m = 10 ** 9 + 7
	t = int(input())
	while t:
		t -= 1
		solve()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	S = list(map(int, input().split()))
	ANS = []
	for elem in S:
		if elem not in ANS:
			ANS.append(elem)
	print(*ANS)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().strip(' ').split()))
	pdic = {}
	s = ''
	for j in p:
		if j not in pdic:
			pdic[j] = 0
			s = s + str(j) + ' '
			if len(pdic) == n:
				break
	print(s.strip(' '))


def Restore(n, a):
	(final, string) = ([], '')
	for i in a:
		if i not in final:
			final.append(i)
	for j in final:
		string += str(j) + ' '
	return string
Lista = []
total = int(input())
for i in range(total * 2):
	All = [int(i) for i in input().split()]
	Lista.append(All)
for j in range(0, len(Lista), 2):
	print(Restore(Lista[j][0], Lista[j + 1]))


from collections import OrderedDict
for _ in range(int(input())):
	input()
	print(' '.join([str(i) for i in OrderedDict.fromkeys(list(map(int, input().split()))).keys()]))


T = int(input())
for t in range(T):
	n = int(input())
	nums = list(map(int, input().split()))
	numset = {}
	for num in nums:
		numset[num] = None
	for key in numset:
		print(key, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a[:n] == a[n:]:
		print(*a[:n])
	else:
		res = []
		for obj in a:
			if obj not in res:
				res.append(obj)
		print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	l = []
	for each in a:
		if each not in l:
			l.append(each)
	print(*l)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr2 = set(arr)
	new = []
	for i in arr:
		if i in arr2:
			new.append(i)
			arr2.remove(i)
	print(*new)


def main():
	n = int(input())
	for i in range(n):
		solve()

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	checked = set()
	finish = []
	for (index, val) in enumerate(arr):
		if val in checked:
			continue
		checked.add(val)
		finish.append(val)
	print(*finish)
main()


def permut(n, a):
	l = []
	for i in range(2 * n):
		if len(l) == n:
			break
		if a[i] not in l:
			l.append(a[i])
	for i in l:
		print(i, end=' ')
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	permut(n, a)
	print()


t = int(input())
while t:
	n = int(input())
	list1 = list(map(int, input().split()))
	dict1 = list(dict.fromkeys(list1).keys())
	print(*dict1)
	t = t - 1


z = int(input())
for y in range(z):
	n = int(input())
	arr = list(map(int, input().split()))
	arr1 = []
	for item in arr:
		if item not in arr1:
			print(item, end=' ')
			arr1.append(item)


t = int(input())
while t:
	t -= 1
	n = int(input())
	ar = list(map(int, input().split()))
	s = set()
	for i in ar:
		if i not in s:
			print(i, end=' ')
			s.add(i)
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(an, t1) = ([l[0]], l[0])
	for i in range(1, 2 * n):
		if l[i] not in an:
			an.append(l[i])
	print(*an)


t = int(input())
for i in range(t):
	n = int(input())
	mylist = list(map(int, input().split(' ')))
	out = []
	for k in mylist:
		if k not in out:
			out.append(k)
	print(' '.join(list(map(str, out))))


t = int(input())
for i in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	p1 = []
	i = 0
	n1 = 0
	while n1 < n:
		if p[i] not in p1:
			p1.append(p[i])
			n1 += 1
		i += 1
	print(*p1)


def solve(N, nums):
	result = []
	hashSet = set()
	for i in range(2 * N):
		if nums[i] not in hashSet:
			result.append(nums[i])
			hashSet.add(nums[i])
	print(*result, sep=' ')
	return
test_cases = int(input())
for case in range(test_cases):
	N = int(input())
	nums = list(map(int, input().split()))
	solve(N, nums)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	found = []
	for j in range(2 * n):
		if not l[j] in found:
			found.append(l[j])
	for j in range(n):
		if j == n - 1:
			print(found[j])
		else:
			print(found[j], end=' ')


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	d = {}
	x = []
	for i in a:
		if i not in d:
			x.append(i)
			d[i] = 1
	print(*x)


import sys
input = sys.stdin.readline

def main():
	for t in range(int(input())):
		n = int(input())
		pp = map(int, input().split())
		s = (n + 1) * [0]
		for pi in pp:
			if s[pi] == 0:
				print(pi, end=' ')
				s[pi] = 1
		print()
main()


import sys
import pprint as pp

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def solver(number, allList):
	result = ''
	resultList = []
	box = [0] * (number + 1)
	for j in range(0, len(allList)):
		num = allList[j]
		if box[num] == 0:
			resultList.append(str(num))
			box[num] = 1
	result = ' '.join(resultList)
	return result
t = II()
for _ in range(t):
	n = II()
	an = LI()
	print('{}'.format(solver(n, an)))


t = int(input())
result = []
for _ in range(t):
	n = int(input())
	ans = []
	permu = [int(x) for x in input().split()]
	for i in permu:
		if i not in ans:
			ans.append(i)
		else:
			continue
	result.append(ans)
for res in result:
	print(*res)


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
t = int(input())
for i in range(t):
	n = int(input())
	l = lnii()
	ans = []
	st = set()
	for j in l:
		if j not in st:
			st.add(j)
			ans.append(j)
	print(*ans)


def tc():
	n = int(input())
	p = [int(x) for x in input().split()]
	ans = []
	seen = set()
	for x in p:
		if x not in seen:
			ans.append(x)
			seen.add(x)
	print(' '.join(map(str, ans)))
T = int(input())
for _ in range(T):
	tc()


t = int(input())
for test in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	m = []
	for i in range(n + 1):
		m.append(0)
	for i in a:
		if m[i] == 0:
			m[i] = 1
			print(i, end=' ')
	print()


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(councils, a, k):
	summ = 0
	for x in a:
		summ += min(x, councils)
	return summ // councils >= k
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	n = int(input())
	a = list(read())
	d = {}
	for x in a:
		y = d.get(x, 0)
		d[x] = y + 1
	ans = list(d.keys())
	print(*ans)
for _ in range(int(input())):
	solve()


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	vis = [False] * 100
	ans = []
	for i in arr:
		if vis[i] == False:
			vis[i] = True
			ans.append(i)
	print(' '.join(map(str, ans)))


t = int(input(''))
for i in range(t):
	input('')
	result_holder = ''
	numbers = list(dict.fromkeys(map(int, input('').split(' '))))
	for num in numbers:
		result_holder += str(num) + ' '
	print(result_holder.strip())


import sys

def main():
	n = int(sys.stdin.readline())
	for i in range(n):
		x = int(sys.stdin.readline())
		arr = list(map(int, sys.stdin.readline().split()))
		count = {}
		for i in arr:
			count[i] = count.get(i, 0) + 1
		for i in count:
			sys.stdout.write(f'{i} ')
		sys.stdout.write('\n')
main()


for _ in range(int(input())):
	am = int(input())
	arr = list(map(int, input().split()))
	was = [False] * am
	out = []
	for i in range(am * 2):
		if was[arr[i] - 1] == False:
			was[arr[i] - 1] = True
			out.append(arr[i])
	print(*out)


t = int(input())

def delete(seq):
	seen = set()
	seen_add = seen.add
	return [x for x in seq if not (x in seen or seen_add(x))]
for h in range(0, t):
	t1 = int(input())
	rep = input()
	rep1 = rep.split()
	for i in range(0, len(rep1)):
		rep1[i] = int(rep1[i])
	rep2 = delete(rep1)
	rep3 = ''
	for j in range(0, len(rep2)):
		rep3 += str(rep2[j]) + ' '
	print(rep3)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split(' ')))
	vis = [False for i in range(n + 1)]
	ans = []
	for a in arr:
		if not vis[a]:
			ans.append(a)
			vis[a] = True
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	d = {}
	for j in range(len(l)):
		if l[j] not in d:
			l1.append(l[j])
			d[l[j]] = 1
	print(*l1)


for _ in range(int(input())):
	_ = int(input())
	a = list(map(int, input().split()))
	dic = {}
	for el in a:
		try:
			_ = dic[el]
		except:
			dic[el] = 1
	print(*list(dic.keys()))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	v = [0] * (n + 1)
	res = []
	for i in lis:
		if v[i] == 0:
			v[i] = 1
			res.append(i)
	print(*res)


t = int(input())
for i in range(t):
	n = int(input())
	str = input().split()
	arr = []
	for i in str:
		arr.append(int(i))
	h = [0 for i in range(n)]
	p = []
	for i in arr:
		if h[i - 1] == 0:
			p.append(i)
			h[i - 1] = 1
	for i in p:
		print(i, end=' ')
	print()


testcases = int(input())
for t in range(testcases):
	number_permut = int(input())
	arr = input().split()
	results = []
	for num in arr:
		if num not in results:
			results.append(num)
	print(' '.join(results))


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	used = [0] * (n + 5)
	cnt = 0
	frnt = []
	end = []
	for i in range(n):
		if used[arr[i]] == 0:
			used[arr[i]] = 1
			frnt.append(arr[i])
		if used[arr[2 * n - 1 - i]] == 0:
			used[arr[2 * n - 1 - i]] = 1
			end.insert(0, arr[2 * n - 1 - i])
	print(' '.join(map(str, frnt)) + ' ' + ' '.join(map(str, end)))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	i = 0
	while len(ans) < n:
		if a[i] not in ans:
			ans.append(a[i])
			i += 1
		else:
			i += 1
	print(*ans)


for i in range(int(input())):
	k = int(input())
	li = list(map(int, input().split()))
	dict = {}
	for i in li:
		if i in dict:
			continue
		else:
			dict.update({i: 1})
	for i in dict:
		print(i, end=' ')
	print()


for T in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	c = [0 for i in range(n + 1)]
	ans = []
	for i in arr:
		if c[i] == 0:
			ans.append(str(i))
			c[i] = 1
	print(' '.join(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [0] + [1] * n
	ans = []
	c = 0
	for i in range(2 * n):
		if b[a[i]] > 0:
			b[a[i]] -= 1
			c += 1
			ans.append(a[i])
		if c == n:
			break
	print(*ans)


import sys
import math
import heapq
from collections import defaultdict, deque
from decimal import *

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
for _ in range(r()):
	n = r()
	ihave = defaultdict(int)
	a = rl()
	b = []
	for i in a:
		if ihave[i] == 0:
			b.append(i)
			ihave[i] = 1
	print(*b)


t = int(input())
for _ in range(t):

	def f7(seq):
		seen = set()
		seen_add = seen.add
		array = [x for x in seq if not (x in seen or seen_add(x))]
		for i in array:
			print(i, end=' ')
		print()
	n = int(input())
	l = list(map(int, input().split()))
	f7(l)


for i in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	lis = []
	a = set()
	for i in range(2 * n):
		if l[i] not in a:
			a.add(l[i])
			lis.append(l[i])
	for i in lis:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	d = dict(zip(range(1, n + 1), [0] * n))
	ans = []
	for el in p:
		if d[el]:
			continue
		d[el] = 1
		ans.append(el)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	freq = {}
	for i in ls:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	ls = list(map(int, freq.keys()))
	print(*ls)


t = int(input())
for turn in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	actually = []
	for i in range(n):
		q = a.pop(0)
		actually.append(q)
		a.remove(q)
	print(' '.join(map(str, actually)))


for i in range(int(input())):
	l = int(input())
	p = list(map(int, input().split()))
	ans = []
	for i in p:
		if i not in ans and len(ans) <= l:
			ans.append(i)
		else:
			continue
	print(' '.join((str(a) for a in ans)))


t = int(input())
for caso in range(t):
	n = int(input())
	nums = list(map(int, input().split(' ')))
	print(*list(dict.fromkeys(nums)))


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	d = {}
	ans = []
	for i in arr:
		if i not in d:
			ans.append(i)
		d[i] = 1
	for i in ans:
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	n = inp()
	x = ip()
	dt = {}
	ans = []
	for i in x:
		if dt.get(i, 1):
			ans.append(i)
			dt[i] = 0
	print(*ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	p = list(map(int, input().split()))
	b = [False for _ in range(n)]
	r = []
	for i in p[:-1]:
		if not b[i - 1]:
			r.append(i)
			b[i - 1] = True
	print(*r)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = list()
	s = set()
	j = 0
	for i in a:
		if i in s:
			ans += [i]
		else:
			s.add(i)
	print(*ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	tem = []
	cka = []
	ck = 0
	for i in range(len(a)):
		if i == 0:
			tem.append(a[i])
			continue
		if len(tem) > len(cka) and a[i] == tem[ck]:
			cka.append(a[i])
			ck += 1
			continue
		else:
			tem.append(a[i])
	for i in tem:
		print(i, end=' ')
	print()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input().split()
	b = []
	a = []
	for i in s:
		if i not in b:
			a.append(i)
			b.append(i)
	print(*a, sep=' ')


T = int(input())
for tt in range(T):
	hh = []
	vis = [0] * 200
	ans = []
	n = int(input())
	hh = list(map(int, input().split()))
	for i in hh:
		if vis[i] == 0:
			ans.append(i)
			vis[i] = 1
	for i in ans:
		print(i, end=' ')


import sys
input = sys.stdin.readline
import math

def inlt():
	return list(map(int, input().split()))
t = inlt()
for i in range(t[0]):
	n = inlt()[0]
	arr = inlt()
	ans = []
	for i in arr:
		flag = True
		for j in ans:
			if j == i:
				flag = False
		if flag:
			ans = ans + [i]
		if len(ans) == n:
			break
	for i in range(len(ans)):
		print(str(ans[i]) + ' ', end='')
	print('')


t = int(input())
n = [0] * t
resp = [[]]
for i in range(0, t):
	n[i] = int(input())
	a = [0] * (2 * n[i])
	s = [0] * n[i]
	string = input().split()
	for j in range(0, 2 * n[i]):
		a[j] = int(string[j])
	s[0] = a[0]
	s[n[i] - 1] = a[2 * n[i] - 1]
	aux = n[i] - 2
	k = 1
	for j in range(1, n[i] * 2 - 1):
		if aux == 0:
			break
		if a[j] != s[0] and a[j] != s[n[i] - 1] and (not a[j] in s):
			s[k] = a[j]
			aux -= 1
			k += 1
	resp.append(s)
del resp[0]
for i in range(0, t):
	for j in range(0, n[i]):
		print(resp[i][j], end=' ')
	print()


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	notcome = [True] * (n + 1)
	sol = []
	for x in a:
		if notcome[x]:
			notcome[x] = False
			sol.append(x)
	print(*sol)


def fun(n, l):
	l1 = []
	for i in range(2 * n):
		if l[i] not in l1:
			l1.append(l[i])
	print(*l1)
for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	fun(n, l)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(j) for j in input().split()[:2 * n]]
	b = []
	for k in range(len(a)):
		if a[k] not in b:
			b.append(a[k])
	for k in range(len(b)):
		if k == len(b) - 1:
			print(b[k])
		else:
			print(b[k], end=' ')


def main():
	T = int(input())
	while T:
		n = int(input())
		arr = list(map(int, input().split()))
		ht = set()
		ans = []
		for a in arr:
			if a not in ht:
				ans.append(a)
				ht.add(a)
			if len(ans) == n:
				break
		for a in ans:
			print(a, end=' ')
		print()
		T -= 1
main()


from sys import stdin
t = int(stdin.readline().strip())
for i in range(t):
	n = int(stdin.readline().strip())
	A = list(map(int, stdin.readline().strip().split(' ')))
	perm = []
	while len(A) > 0:
		temp = A.pop(0)
		perm.append(temp)
		A.remove(temp)
	print(*perm)


from collections import Counter
testCases = int(input())
for t in range(testCases):
	n = int(input())
	nums = list(map(int, input().split(' ')))
	ls1 = []
	ls2 = []
	index = 0
	for num in nums:
		if index < len(ls1) and num == ls1[index]:
			ls2.append(num)
			index += 1
		else:
			ls1.append(num)
	print(' '.join(map(str, ls1)))