n, m = map(int,input().split())
lst = []
for _ in range(n):
    l = list(map(int, input().split()))
    lst.append(l[1:])

ansset = set(lst[0])
for i in range(1,n):
    ansset = ansset & set(lst[i])

print(len(ansset)) n, m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m lst = [] lst [] for _ in range(n):
    l = list(map(int, input().split()))
    lst.append(l[1:]) _ range(n) range n l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split lst.append(l[1:]) lst.append lst append l[1:] l 1: 1 ansset = set(lst[0]) ansset set(lst[0]) set lst[0] lst 0 for i in range(1,n):
    ansset = ansset & set(lst[i]) i range(1,n) range 1 n ansset = ansset & set(lst[i]) ansset ansset & set(lst[i]) ansset set(lst[i]) set lst[i] lst i print(len(ansset)) print len(ansset) len ansset n, m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m ansset = set(lst[0]) set(lst[0]) ansset ansset = ansset & set(lst[i]) ansset & set(lst[i]) ansset lst = [] [] lst l = list(map(int, input().split())) list(map(int, input().split())) l
n, m = map(int,input().split())
lst = []
for _ in range(n):
    l = list(map(int, input().split()))
    lst.append(l[1:])

ansset = set(lst[0])
for i in range(1,n):
    ansset = ansset & set(lst[i])

print(len(ansset))
