DefaultDict Tutorial

  • + 0 comments
    lengths = input().split()
    target_lst  = []
    seek_lst = []
    for n in range(int(lengths[0])):
        target_lst.append(input())
    for n in range(int(lengths[1])):
        seek_lst.append(input())
     
    for n in seek_lst:
        target_index = []
        if n in target_lst:
            for c,x in enumerate(target_lst):
                if x==n:
                    target_index.append(str(c+1))
            print(' '.join(target_index))
        else:
            print("-1")