N, M = map(int, input().split())
S = set([x for x in range(1,M+1)])

for i in range(N):
 
  A = list(map(int, input().split()))
  B = set(A[1:])
 
  S = S & B
print(len(S)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M x for x in range(1,M+1) for x in range(1,M+1) x range(1,M+1) range 1 M+1 M 1 for x in range(1,M+1) x S = set([x for x in range(1,M+1)]) S set([x for x in range(1,M+1)]) set [x for x in range(1,M+1)] for i in range(N):
 
  A = list(map(int, input().split()))
  B = set(A[1:])
 
  S = S & B i 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 S = S & B S S & B S B print(len(S)) print len(S) len S B = set(A[1:]) set(A[1:]) B A = list(map(int, input().split())) list(map(int, input().split())) A M = map(int, input().split()) map(int, input().split()) M S = S & B S & B S N, M = map(int, input().split()) map(int, input().split()) N S = set([x for x in range(1,M+1)]) set([x for x in range(1,M+1)]) S
N, M = map(int, input().split())
S = set([x for x in range(1,M+1)])

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