n,m=map(int,input().split())
ans=list(range(1,m+1))
for i in range(n):
    l=list(map(int,input().split()))[1:]
    ans=list(set(ans)&set(l))
print(len(ans)) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ans=list(range(1,m+1)) ans list(range(1,m+1)) list range(1,m+1) range 1 m+1 m 1 for i in range(n):
    l=list(map(int,input().split()))[1:]
    ans=list(set(ans)&set(l)) i range(n) range n l=list(map(int,input().split()))[1:] l list(map(int,input().split()))[1:] (map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 1: 1 ans=list(set(ans)&set(l)) ans list(set(ans)&set(l)) list set(ans)&set(l) set(ans) set ans set(l) set l print(len(ans)) print len(ans) len ans n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m ans=list(range(1,m+1)) list(range(1,m+1)) ans ans=list(set(ans)&set(l)) list(set(ans)&set(l)) ans l=list(map(int,input().split()))[1:] list(map(int,input().split()))[1:] l
n,m=map(int,input().split())
ans=list(range(1,m+1))
for i in range(n):
    l=list(map(int,input().split()))[1:]
    ans=list(set(ans)&set(l))
print(len(ans))