You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.

Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code.


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n, m \le 10$) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints.

The next line contains $n$ distinct space-separated integers $x_1, x_2, \ldots, x_n$ ($0 \le x_i \le 9$) representing the sequence.

The next line contains $m$ distinct space-separated integers $y_1, y_2, \ldots, y_m$ ($0 \le y_i \le 9$) — the keys with fingerprints.


-----Output-----

In a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.


-----Examples-----
Input
7 3
3 5 7 1 6 2 8
1 2 7

Output
7 1 2

Input
4 4
3 4 1 0
0 1 7 9

Output
1 0



-----Note-----

In the first example, the only digits with fingerprints are $1$, $2$ and $7$. All three of them appear in the sequence you know, $7$ first, then $1$ and then $2$. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.

In the second example digits $0$, $1$, $7$ and $9$ have fingerprints, however only $0$ and $1$ appear in the original sequence. $1$ appears earlier, so the output is 1 0. Again, the order is important.

Difficulty: interview

Starter code:

Solutions:
input()
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for x in a:
    if x in b:
        print(x, end=' ')
print()


a, b = input().split()
a, b = int(a), int(b)

arr = list(map(int, input().split()))
a2 = list(map(int, input().split()))

for i in arr:
    if i in a2:
        print(i, end=' ')


n, m = [int(v) for v in input().split()]
x = [int(v) for v in input().split()]
y = {int(v) for v in input().split()}

print(' '.join(str(v) for v in x if v in y))


input()
x = [int(a) for a in input().split()]
y = [int(a) for a in input().split()]

z = [str(i) for i in x if i in y]

print(" ".join(z))


n,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in a:
    if b.count(i) >= 1:
        print(i,end=" ")


(n, n) = map(int, input().split())

lst1 = [int(x) for x in input().split()]

lst2 = [int(x) for x in input().split()]

for x in lst1:
    if x in lst2:
        print(x, end = ' ')


n, m = map(int, input().split())
xs = list(map(int, input().split()))
ys = set(map(int, input().split()))
for i in xs:
    if i in ys:
        print(i, end = ' ')

n,m=map(int,input().split())
ar=list(map(int,input().split()))
br=list(map(int,input().split()))
ans=[]
for x in ar:
    if x in br:
        ans.append(x)
print(*ans)

# your code goes here
n, m = map(int, input().split())

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

res = [x for x in a if x in b]

print(*res)

n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
y = set(map(int, input().split()))
ans = []
for but in x:
    if but in y:
        ans.append(but)
print(' '.join(map(str, ans)))


input()
l = [ int(x) for x in input().split()]
l2 = [ int(x) for x in input().split()]

for ele in l:
    if ele in l2:
        print(ele,end=" ") 

n,m=(map(int,input().strip().split(' ')))
arr=list(map(int,input().strip().split(' ')))
brr=list(map(int,input().strip().split(' ')))
ans=[]
for i in arr:
  if i in brr:
    ans.append(i)
for i in ans:
  print(i,end=' ')

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


N, M = list(map(int, input().split()))
X = [int(x) for x in input().split()]
Y = [int(x) for x in input().split()]
print(*[x for x in X if x in Y])


n,m = map(int,input().split())
xi = list(map(int,input().split()))
yi = list(map(int,input().split()))
ans = []
for i in xi:
    if i in yi:
        print(i,end=" ")


a=[int(q) for q in input().strip().split()]
b=[int(q) for q in input().strip().split()]
c=[int(q) for q in input().strip().split()]
d=[]
for k in range(len(b)):
    if b[k]in c:
        d.append(str(b[k]))
print(' '.join(d))

m, n = [int(i) for i in input().split()]
cons = input().split()
real = [i for i in input().split()]

ht = {}
for i in real:
	ht[i] = True

ans = []
for i in cons:
	if ht.get(i, None) == True:
		ans.append(i)

print(" ".join(ans))

n,m=map(int,input().split())
x=[*map(int,input().split())]
have=[False]*10
for i in map(int,input().split()):
  have[i]=True
for i in x:
  if have[i]:
    print(i,end=' ')

n,m=[int(x) for x in input().split()]
s=[int(x) for x in input().split()]
f=[int(x) for x in input().split()]
l=[]
for x in s:
    if x in f:
        l.append(str(x))
print(" ".join(l))

#JMD
#Nagendra Jha-4096
 
#a=list(map(int,sys.stdin.readline().split(' ')))
#n,k,s= map(int, sys.stdin.readline().split(' '))
 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
n,m= map(int, sys.stdin.readline().split(' '))
a=list(map(int,sys.stdin.readline().split(' ')))
b=list(map(int,sys.stdin.readline().split(' ')))
ans=[]
for aa in a:
	if(aa in b):
		ans.append(aa)
print(*ans)
	
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

from math import ceil, log
t = 1
for test in range(t):
    n,m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = []
    for key in a:
        if key in b:
            ans.append(key)
    print(*ans)


    



def go():
    n, m = (int(i) for i in input().split(' '))
    a = [int(i) for i in input().split(' ')]
    b = [int(i) for i in input().split(' ')]
    c = []
    for i in b:
        try:
            c.append(a.index(i))
        except:
            continue
    
    return ' '.join(str(a[i]) for i in sorted(c))

print(go())


n, m = map(int, input().split())
x = [int(q) for q in input().split()]
y = [int(q) for q in input().split()]
ans = []
for i in range(len(x)):
    if x[i] in y:
        ans.append(x[i])
for item in ans:
    print(item, end=" ")