We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Collections
- DefaultDict Tutorial
- Discussions
DefaultDict Tutorial
DefaultDict Tutorial
Sort by
recency
|
1075 Discussions
|
Please Login in order to post a comment
from collections import defaultdict n,m = list(map(int, input().split()))
A = defaultdict(list) for i in range(1, n+1): A[input()].append(i)
for _ in range(m): print(*A[input()] or [-1])