DefaultDict Tutorial

  • + 0 comments
    n, m = map(int, input().strip().split(" "))
    A = []
    for _ in range(n):
        A.append( input().strip() )
    
    for _ in range(m):
        str = input().strip() 
        l = list( [index + 1 for index, value in enumerate(A) if value == str] )
        print(-1) if len(l) == 0 else print(*l)