N, M = map(int,input().split())
KA = []
for n in range(N):
    KA.append([ka for ka in map(int,input().split())])

ans = set(range(1,M+1))

for ka in KA:
    ans = ans & set(ka[1:])

print(len(ans)) N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M KA = [] KA [] for n in range(N):
    KA.append([ka for ka in map(int,input().split())]) n range(N) range N ka for ka in map(int,input().split()) for ka in map(int,input().split()) ka map(int,input().split()) map int input().split() ().split () input split for ka in map(int,input().split()) ka KA.append([ka for ka in map(int,input().split())]) KA.append KA append [ka for ka in map(int,input().split())] ans = set(range(1,M+1)) ans set(range(1,M+1)) set range(1,M+1) range 1 M+1 M 1 for ka in KA:
    ans = ans & set(ka[1:]) ka KA ans = ans & set(ka[1:]) ans ans & set(ka[1:]) ans set(ka[1:]) set ka[1:] ka 1: 1 print(len(ans)) print len(ans) len ans M = map(int,input().split()) map(int,input().split()) M ans = ans & set(ka[1:]) ans & set(ka[1:]) ans N, M = map(int,input().split()) map(int,input().split()) N ans = set(range(1,M+1)) set(range(1,M+1)) ans KA = [] [] KA
N, M = map(int,input().split())
KA = []
for n in range(N):
    KA.append([ka for ka in map(int,input().split())])

ans = set(range(1,M+1))

for ka in KA:
    ans = ans & set(ka[1:])

print(len(ans))