N, M = map(int, input().split())
ans = set(range(1, M+1))
for i in range(N):
  K, *A = map(int, input().split())
  ans = ans & set(A)
print(len(ans)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M ans = set(range(1, M+1)) ans set(range(1, M+1)) set range(1, M+1) range 1 M+1 M 1 for i in range(N):
  K, *A = map(int, input().split())
  ans = ans & set(A) i range(N) range N K, *A = map(int, input().split()) K map(int, input().split()) map int input().split() ().split () input split *A A ans = ans & set(A) ans ans & set(A) ans set(A) set A 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 = set(range(1, M+1)) set(range(1, M+1)) ans ans = ans & set(A) ans & set(A) ans K, *A = map(int, input().split()) map(int, input().split()) K
N, M = map(int, input().split())
ans = set(range(1, M+1))
for i in range(N):
  K, *A = map(int, input().split())
  ans = ans & set(A)
print(len(ans))