DefaultDict Tutorial

  • + 0 comments
    from collections import defaultdict
    
    n, m = input().split()
    a = defaultdict(list)
    [a[input()].append(i+1) for i in range(int(n))]
    [print(*a[input()] or [-1]) for i in range(int(m))]