You are viewing a single comment's thread. Return to all comments →
from collections import defaultdict if __name__ == '__main__': n, m = map(int, input().split()) words_dict = defaultdict(list) for i in range(n): words_dict['A'].append(input()) for i in range(m): words_dict['B'].append(input()) for word in words_dict['B']: indexes = [i+1 for i, x in enumerate(words_dict['A']) if x == word] if indexes: print(*indexes)
if word not in words_dict['A']: print(-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 →