#!python # -*- coding: utf-8 -*- def main(): N = int(input()) seki = [[] for i in range(20)] for t in range(N): input_list = input().split() if input_list[0] == '0': n, m = map(int, input_list[1:3]) A = input_list[3:] seki[n - 1] = A if input_list[0] == '1': for i, kyaku in enumerate(seki): neta = input_list[1] if neta in kyaku: kyaku.remove(neta) print(i + 1) break else: print(-1) if input_list[0] == '2': c = int(input_list[1]) seki[c - 1].clear() if __name__ == '__main__': main()