N,M = map(int,input().split())
ls = [0]*(M+1)
for i in range(N):
    ls1 = list(map(int,input().split()))
    a = ls1.pop(0)
    for j in range(a):
        ls[ls1[j]] += 1
print(ls.count(N)) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M ls = [0]*(M+1) ls [0]*(M+1) [0] 0 M+1 M 1 for i in range(N):
    ls1 = list(map(int,input().split()))
    a = ls1.pop(0)
    for j in range(a):
        ls[ls1[j]] += 1 i range(N) range N ls1 = list(map(int,input().split())) ls1 list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split a = ls1.pop(0) a ls1.pop(0) ls1.pop ls1 pop 0 for j in range(a):
        ls[ls1[j]] += 1 j range(a) range a ls[ls1[j]] += 1 ls[ls1[j]] ls ls1[j] ls1 j 1 print(ls.count(N)) print ls.count(N) ls.count ls count N ls1 = list(map(int,input().split())) list(map(int,input().split())) ls1 a = ls1.pop(0) ls1.pop(0) a N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M ls = [0]*(M+1) [0]*(M+1) ls
N,M = map(int,input().split())
ls = [0]*(M+1)
for i in range(N):
    ls1 = list(map(int,input().split()))
    a = ls1.pop(0)
    for j in range(a):
        ls[ls1[j]] += 1
print(ls.count(N))