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