Alice has an array A of length N which is initially a *permutation*. She dislikes K numbers which are B_{1}, B_{2}, \ldots, B_{K} all of which are distinct. Therefore, she removes all the occurrences of these numbers from A. The order of the remaining elements of the A does not change. 

Can you find out the resulting array A?

Note: A *permutation* of length N is an array where every integer from 1 to N occurs exactly once.

------ Input Format ------ 

- The first line contains a single integer T — the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer N — the size of the array A.
- The second line of each test case contains N integers A_{1}, A_{2}, \ldots, A_{N} denoting the array A.
- The third line of each test case contains an integer K — the size of the array B.
- The fourth line of each test case contains K integers B_{1}, B_{2}, \ldots, B_{K} denoting the numbers which Alice dislikes.

------ Output Format ------ 

For each test case, output the resulting array A after the removal of all occurrences of B_{1}, B_{2}, \ldots B_{K}.

It is guaranteed that there will be at least one element in the resulting array.

------ Constraints ------ 

$1 ≤ T ≤ 1000$
$1 ≤ K < N ≤ 10^{5}$
$1 ≤A_{i}, B_{i} ≤N$
$A$ is initially a *permutation*.
$B_{i} \ne B_{j}$ when $(i \ne j)$
- Sum of $N$ over all test cases does not exceed $2 \cdot 10^{5}$.

----- Sample Input 1 ------ 
3
4
4 1 3 2
2
3 1
9
5 2 9 1 8 6 4 3 7
3
5 8 9
5
3 4 5 1 2
2
2 3

----- Sample Output 1 ------ 
4 2
2 1 6 4 3 7
4 5 1

----- explanation 1 ------ 
Test Case 1: Here $A = [4, 1, 3, 2]$ and $B = [3, 1]$. The resulting array $A$ after removing all the numbers which Alice dislikes is $[4, 2]$.

Note that here $[2, 4]$ is an incorrect answer since the order of elements should be the same as in the original array.

Test Case 2: Here $A = [5, 2, 9, 1, 8, 6, 4, 3, 7]$ and $B = [5, 8, 9]$. The resulting array $A$ after removing all the numbers which Alice dislikes is $[2, 1, 6, 4, 3, 7]$.

Test Case 3: Here $A = [3, 4, 5, 1, 2]$ and $B = [2, 3]$. The resulting array $A$ after removing all the numbers which Alice dislikes is $[4, 5, 1]$.

Difficulty: EASY
Tags: Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	b = int(input())
	m = set(map(int, input().split()))
	for j in l:
		if j not in m:
			print(j, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	k = int(input())
	B = set(map(int, input().split()))
	for i in A:
		if i not in B:
			print(i, end=' ')
	print()


t = int(input())
for ni in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	k = int(input())
	b = set([int(i) for i in input().split()])
	for i in range(n):
		if a[i] not in b:
			print(a[i], end=' ')
		else:
			continue
	print()


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


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	m = int(input())
	b = list(map(int, input().split(' ')))
	d = {}
	for i in range(n):
		d[i + 1] = 0
	for i in b:
		d[i] = 1
	ans = []
	for i in a:
		if d[i] == 0:
			ans.append(i)
	for i in ans:
		print(i, end=' ')
	print()


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = int(input())
	b = set(map(int, input().split()))
	for i in range(n):
		if a[i] not in b:
			print(a[i], end=' ')
	print()


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	K = int(input())
	B = set(map(int, input().split()))
	C = [-1] * (N - K)
	j = 0
	for i in range(N):
		if A[i] not in B:
			C[j] = A[i]
			j += 1
	print(*C)


for _ in range(int(input())):
	an = int(input())
	a = list(map(int, input().split()))
	bn = int(input())
	b = list(map(int, input().split()))
	b = set(b)
	temp = [i for i in a if i not in b]
	for i in range(len(temp)):
		print(temp[i], end=' ')
	print()


t = int(input())
while t != 0:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	k = int(input())
	b = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		dic[a[i]] = i
	for i in range(k):
		dic.pop(b[i])
	arr = [0] * n
	for i in dic:
		arr[dic[i]] = i
	for i in arr:
		if i != 0:
			print(i, end=' ')
	print()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = int(input())
	b = list(map(int, input().split()))
	list1 = []
	b = set(b)
	temp = [i for i in a if i not in b]
	for i in range(len(temp)):
		print(temp[i], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	k = int(input())
	l2 = set(map(int, input().split()))
	s = ' '
	for i in l1:
		if i not in l2:
			s += str(i) + ' '
	print(s[:len(s) - 1])


from collections import Counter, UserString
from math import log2
mod = lambda n: int(n % (10 ** 9 + 7))
_fc = [1]
for i in range(1, 1000001):
	_fc.append(i * _fc[i - 1])
	_fc[i] = mod(_fc[i])

def fact(n):
	if -1000001 < n < 1000001:
		if n > -1:
			return _fc[n]
		else:
			return int('-' + str(_fc[abs(n)]))
	else:
		raise ValueError('values only from 1000000 to -1000000 can be factorialized\n')

def yn(b, caps=False, y='Yes', n='No'):
	if b:
		returning = y
	else:
		returning = n
	if caps == 2:
		return returning.lower()
	elif caps:
		return returning.upper()
	return returning

def prob(l, n):
	return l.count(n) / len(l)

def isSubseq(s1, s2):
	(n, m) = (len(s1), len(s2))
	(i, j) = (0, 0)
	while i < n and j < m:
		if s1[i] == s2[j]:
			i += 1
		j += 1
	return i == n

def isPrime(n):
	if n > 1:
		for i in range(2, int(n ** 0.5) + 1):
			if not n % i:
				return False
		else:
			return True
	return True

def percentDiff(n, diff):
	return n + n * (diff / 100)

def prodLst(l1, nl):
	if isinstance(nl, int):
		return [i * nl for i in l1]
	else:
		return [i * j for (i, j) in zip(l1, nl)]

def divLst(l1, nl, mxMn=False):
	if isinstance(nl, int):
		return [i // nl for i in l1]
	elif mxMn:
		return [max(i, j) // min(i, j) for (i, j) in zip(l1, nl)]
	else:
		return [i // j for (i, j) in zip(l1, nl)]

def modLst(l, n):
	return [i % n for i in l]

def sumLst(l1, nl):
	if isinstance(nl, int):
		return [i + nl for i in l1]
	else:
		return [i + j for (i, j) in zip(l1, nl)]

def absLst(l):
	return [abs(i) for i in l]

def diffLst(l1, nl, isAbs=False):
	if isinstance(nl, int):
		returning = [i - nl for i in l1]
	else:
		returning = [i - j for (i, j) in zip(l1, nl)]
	if isAbs:
		return absLst(returning)
	else:
		return returning

def remCommonOccurs(l, rl):
	srl = set(rl)
	returning = []
	for i in l:
		if i not in rl:
			returning.append(i)
	return returning

def remPosNeg(l, posNeg=False):
	returning = []
	if not posNeg:
		for i in l:
			if i >= 0:
				returning.append(i)
	else:
		for i in l:
			if i < 0:
				returning.append(i)
	return returning

def flip(nl):
	if isinstance(nl, int):
		return -nl
	elif isinstance(nl, list):
		return [-i for i in nl]

def ev(n):
	return not n & 1

def decimal(n):
	return round(n + 0.5)

def printabs(n):
	print(abs(n))

def printm(n):
	print(mod(n))

def printy(b, caps=False, y='Yes', n='No'):
	print(yn(b, caps, y, n))

class mutableStr(UserString):

	def ins(self, n, s):
		if n < 0:
			self.data = self.data = ''.join(list(self.data)[:n + 1]) + s + ''.join(list(self.data)[n + 1:])
		else:
			self.data = ''.join(list(self.data)[:n]) + s + ''.join(list(self.data)[n:])

	def rem(self, s):
		self.data = self.data.replace(s, '')
alphabetOrd = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]
alphabet = list('abcdefghijklmnopqrstuvwxyz')
bint = lambda b: int(b, 2)
r2 = lambda n: range(1, n + 1)
rl = lambda *l: range(len(l[0])) if len(l) == 1 else range(l[0], len(l[1]))
alph = lambda s: s.isalpha()
sl = lambda l: list(set(l))
inf = float('inf')
soi = lambda : sorted(input())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
si = lambda : mutableStr(str(input()))
lsi = lambda : list(input())
sepi = lambda : map(int, input().split())
seti = lambda : set(map(int, input().split()))
for t in range(int(input())):
	lenOfLst = ii()
	lst = li()
	lenOfDislikes = ii()
	dislikes = seti()
	ans = remCommonOccurs(lst, dislikes)
	print(*ans)


for jk in range(int(input())):
	size = int(input())
	arr = list(map(int, input().split()))
	s = int(input())
	a = set(list(map(int, input().split())))
	l = []
	for i in arr:
		if i not in a:
			print(i, end=' ')
	print()


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


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	forbidden = [False] * (len(a) + 1)
	k = int(input())
	b = list(map(int, input().split()))
	for v in b:
		forbidden[v] = True
	good = []
	for v in a:
		if not forbidden[v]:
			good += [v]
	print(*good)


r = int(input())
while r > 0:
	r = r - 1
	aa = int(input())
	aar = list(map(int, input().split()))
	sa = int(input())
	sar = list(map(int, input().split()))
	par = set(sar)
	z = []
	for i in aar:
		if i not in par:
			z.append(i)
	print(*z)


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


for _ in range(int(input())):
	a_len1 = int(input())
	a1 = list(map(int, input().split(' ')))
	a_len2 = int(input())
	a2 = set(map(int, input().split(' ')))
	ans = [sublist for sublist in a1 if sublist not in a2]
	print(*ans)


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


for _ in range(int(input())):
	n = int(input())
	lst1 = list(map(int, input().split()))
	k = int(input())
	lst2 = set(map(int, input().split()))
	lst3 = []
	for item in lst1:
		if item not in lst2:
			lst3.append(item)
	print(*lst3)


occurance = int(input())
for j in range(occurance):
	arr_len = int(input())
	arr_a = list(map(int, input().split()))
	b = int(input())
	del_arr = set(map(int, input().split()))
	updated_arr = []
	for i in arr_a:
		if i not in del_arr:
			updated_arr.append(i)
	print(*updated_arr)


def con(d, c):
	l1 = [0] * 100001
	for i in d:
		l1[i] = 1
	return l1
a = int(input())
for a in range(a):
	b = int(input())
	l = list(map(int, input().split(' ')))
	c = int(input())
	d = list(map(int, input().split(' ')))
	l1 = con(d, c)
	for j in range(b):
		if not l1[l[j]]:
			print(l[j], end=' ')
	print()


def dpl(b, n):
	dp = [0] * 100001
	for x in b:
		dp[x] = 1
	return dp
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = int(input())
	b = list(map(int, input().split()))
	l = dpl(b, k)
	for x in range(n):
		if not l[a[x]]:
			print(a[x], end=' ')
	print()


t = int(input())
for p in range(0, t):
	n = int(input())
	li = list(map(int, input().split()))
	n1 = int(input())
	li1 = list(map(int, input().split()))
	li1 = set(li1)
	for i in li:
		if i not in li1:
			print(i, end=' ', sep='')
	print()


T = int(input())
for i in range(0, T):
	n = int(input())
	x = list(map(int, input().split()))
	k = int(input())
	y = list(map(int, input().split()))
	y = set(y)
	for j in x:
		if j not in y:
			print(j, end=' ')
	print()


for i in range(int(input())):
	x = int(input())
	x1 = list(map(int, input().split()))
	y = int(input())
	y1 = set(map(int, input().split()))
	list1 = [ele for ele in x1 if ele not in y1]
	print(*list1)


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


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


for _ in range(int(input())):
	a = int(input())
	arr1 = list(map(int, input().split()))[:a]
	b = int(input())
	arr2 = set(map(int, input().split()))
	for i in arr1:
		if i not in arr2:
			print(i, end=' ')
	print()


for i in range(int(input())):
	a1 = int(input())
	a = list(map(int, input().split()))
	b1 = int(input())
	b = set(map(int, input().split()))
	for j in a:
		if j in b:
			continue
		else:
			print(j, end=' ')
	print()


def solve():
	t = int(input())
	for _ in range(t):
		n = int(input())
		l = list(map(int, input().split()))
		k = int(input())
		b = set(map(int, input().split()))
		c = [i for i in l if i not in b]
		print(*c)
solve()


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	k = int(input())
	b = [int(x) for x in input().split()]
	idx = {}
	for i in range(n):
		idx[a[i]] = i
	for val in b:
		a[idx[val]] = 0
	for num in a:
		if num:
			print(num, end=' ')
	print()


T = int(input())
for tc in range(T):
	n = int(input())
	s = list(map(int, input().split()))
	nn = int(input())
	ss = set(map(int, input().split()))
	for i in s:
		if i not in ss:
			print(i, end=' ')
	print(' ')


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


for i in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	m = int(input())
	b = list(map(int, input().split()))
	b.sort()
	out = []
	for k in li:
		boo = False
		(i, j) = (0, m - 1)
		while i <= j:
			mid = (i + j) // 2
			if b[mid] < k:
				i = mid + 1
			elif b[mid] > k:
				j = mid - 1
			else:
				boo = True
				break
		if not boo:
			out.append(k)
	print(*out)


for _ in range(int(input())):
	x = int(input())
	l = list(map(int, input().split()))
	y = int(input())
	k = list(map(int, input().split()))
	z = [0] * x
	tl = []
	for i in range(y):
		z[k[i] - 1] = 1
	for i in l:
		if z[i - 1] != 1:
			tl.append(i)
	print(*tl)


t = int(input())
for i in range(t):
	n = int(input())
	lst1 = [int(x) for x in input().split()]
	m = int(input())
	lst2 = [int(x) for x in input().split()]
	lst2 = set(lst2)
	for x in lst1:
		if x not in lst2:
			print(x, end=' ')
	print(' ')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	k = int(input())
	b = set(map(int, input().split(' ')))
	c = ' '
	for j in a:
		if j not in b:
			c = c + str(j) + ' '
	print(c)


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	K = int(input())
	B = set(map(int, input().split()))
	C = ''
	for x in A:
		if x not in B:
			C = C + str(x) + ' '
	print(C)


for _ in range(int(input())):
	N = int(input())
	A = [x for x in input().split()]
	K = int(input())
	B = set([x for x in input().split()])
	print(*[a for a in A if a not in B])


t = int(input())
for i in range(t):
	n = int(input())
	a = list(input().split())
	k = int(input())
	b = list(input().split())
	b = set(b)
	x = [i for i in a if i not in b]
	print(*x)


t = int(input())
for v in range(t):
	n = int(input())
	l1 = [int(i) for i in input().split()]
	m = int(input())
	l2 = set([int(i) for i in input().split()])
	for i in l1:
		if i not in l2:
			print(i, end=' ')
	print()


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


for _ in range(int(input())):
	N_a = int(input())
	arr_a = list(map(int, input().split()))
	N_b = int(input())
	arr_b = set(map(int, input().split()))
	for a in arr_a:
		if a not in arr_b:
			print(a, end=' ')
	print()


for i in range(0, int(input())):
	n = int(input())
	l = list(input().split())
	k = int(input())
	m = list(input().split())
	m = set(m)
	z = [ele for ele in l if ele not in m]
	print(*z)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	k = int(input())
	b = list(map(int, input().split()))
	b = set(b)
	for x in a:
		if x in b:
			pass
		else:
			print(int(x), end=' ')
	print('\n')


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	r = int(input())
	brr = set(map(int, input().split()))
	for i in arr:
		if i in brr:
			continue
		else:
			print(i, end=' ')
	print()


for x in range(int(input())):
	size1 = input()
	line1 = input().split()
	size2 = input()
	line2 = set(input().split())
	for x in line1:
		if x not in line2:
			print(x, end=' ')
	print('')


tc = int(input())
for i in range(tc):
	a = int(input())
	x = list(map(int, input().split()))
	b = int(input())
	y = set(map(int, input().split()))
	o = []
	for j in x:
		if j in y:
			continue
		else:
			o.append(j)
	print(*o)


import numpy as np
for i in range(int(input())):
	int(input())
	a = [int(x) for x in input().split()]
	int(input())
	b = set([int(x) for x in input().split()])
	a = [num for num in a if num not in b]
	print(*a)