from bisect import bisect_left
n,k=map(int, input().split())
a=[int(x) for x in input().split()]
F=[int(x) for x in input().split()]
for i in F:
x = bisect_left(a, i)
if x != len(a) and a[x] == i:
print(x+1)
else:
print(0)
from bisect import bisect
n,k=map(int, input().split())
a=[int(x) for x in input().split()]
F=[int(x) for x in input().split()]
for i in F:
x = bisect(a, i)
if x != 0 and a[x-1] == i:
print(x)
else:
print(0)