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

Difficulty: introductory

Starter code:

Solutions:
t = int(input())

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

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 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()


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)

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)
    


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())
    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)


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()) 
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() 

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()

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 t in range(int(input())):
    n = int(input())
    a = list(map(int,input().split()))
    
    s = set()
    l = []
    for i in a:
        if not i in s:
            l.append(i)
            s.add(i)
    print(" ".join(map(str,l)))

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))

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()
    #s = input()
    #n,m = MAP()
    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)


#code
t=int(input())
while(t>0):
    t-=1
    n=int(input())
    li=list(map(int,input().split()))
    a=[0 for i in range(n+1)]
    for i in li:
        if a[i]==0:
            print(i,end=' ')
            a[i]=1
    print()





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()
	 



	

"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


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
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
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 list(map(int, data().split()))
def ssp(): return list(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)


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

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=" ")


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)


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)


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


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)

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 OrderedDict
for _ in range(int(input())):
    n = int(input())
    l = [*list(map(int,input().split()))]
    print(*list(OrderedDict.fromkeys(l)))


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)

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()

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()


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))

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)