import sys
input = sys.stdin.readline
N, M = map(int, input().split())
l = [0] # 리스트: l[번호] = 이름
d = dict() # 딕셔너리: key=이름, value=번호
for i in range(N):
name = input().rstrip()
l.append(name)
d[name] = i+1
for _ in range(M):
q = input().rstrip()
if q.isnumeric():
print(l[int(q)])
else:
print(d[q])
str.isnumberic()
, str.isdigit()
...