N,M = map(int,input().split())
B = set(m for m in range(1,1+M))

for n in range(N):
  A = list(map(int,input().split()))
  B&=set(A[1:])

print(len(B)) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M B = set(m for m in range(1,1+M)) B set(m for m in range(1,1+M)) set m for n in range(N):
  A = list(map(int,input().split()))
  B&=set(A[1:]) n range(N) range N A = list(map(int,input().split())) A list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split B&=set(A[1:]) B set(A[1:]) set A[1:] A 1: 1 print(len(B)) print len(B) len B N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M A = list(map(int,input().split())) list(map(int,input().split())) A B = set(m for m in range(1,1+M)) set(m for m in range(1,1+M)) B B&=set(A[1:]) set(A[1:]) B
N,M = map(int,input().split())
B = set(m for m in range(1,1+M))

for n in range(N):
  A = list(map(int,input().split()))
  B&=set(A[1:])

print(len(B))