import collections
import sys
from typing import List
def solution(n: int, m: int) -> List[str]:
answer = []
index_name_map = collections.defaultdict(int)
name_index_map = collections.defaultdict(str)
for i in range(1, n + 1):
name = sys.stdin.readline().rstrip()
name_index_map[name] = i
index_name_map[i] = name
for j in range(m):
name = sys.stdin.readline().rstrip()
if name.isdigit():
answer.append(index_name_map[int(name)])
continue
answer.append(name_index_map[name])
return answer
N, M = map(int, sys.stdin.readline().split())
print(*solution(N, M), sep='\n')
Leave a comment