N,M = map(int,input().split()) ls = [1]*(N) dic = dict() for i in range(M): a,b = map(int, input().split()) l = list(map(lambda x :int(x)-1, input().split())) a -= 1 ls[a] = 0 dic[a] = l for _ in range(N): for i in dic.keys(): f = True for j in dic[i]: if ls[j] == 0: f = False break if f: ls[i] = 1 continue print(ls.count(1))