You are viewing a single comment's thread. Return to all comments →
from collections import defaultdict n,m,dd = map(int,input().split()),defaultdict(list)
for i in range(n): dd[input()].append(i+1)
for _ in range(m): print(' '.join(map(str,dd.get(input(),[-1]))))
Seems like cookies are disabled on this browser, please enable them to open this website
DefaultDict Tutorial
You are viewing a single comment's thread. Return to all comments →
from collections import defaultdict n,m,dd = map(int,input().split()),defaultdict(list)
for i in range(n): dd[input()].append(i+1)
for _ in range(m): print(' '.join(map(str,dd.get(input(),[-1]))))