Input Format
The first line contains integers,  and  separated by a space.
The next  lines contains the words belonging to group .
The next  lines contains the words belonging to group .
Output Format
Output  lines.
The  line should contain the -indexed positions of the occurrences of the  word separated by spaces.

### Problem solution in python 3 programming language.

# Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import defaultdict
d = defaultdict(list)
list1=[]
n, m = map(int,input().split())
for i in range(1, n+1):
d[input()].append(str(i))
for i in range(m):
b = input()
if b in d: print(' '.join(d[b]))
elseprint(-1)

### Problem solution in python 2 programming language.

# Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import defaultdict
d = defaultdict(list)
list1=[]
n, m = map(int,raw_input().split())
for i in range(1, n+1):
d[raw_input()].append(str(i))
for i in range(m):
b = raw_input()
if b in d: print ' '.join(d[b])
elseprint -1