n,m=map(int, input().split())
A=set(range(1, m+1))
for _ in range(n):
  a,*b=map(int, input().split())
  A = A & set(b)
print(len(A)) n,m=map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m A=set(range(1, m+1)) A set(range(1, m+1)) set range(1, m+1) range 1 m+1 m 1 for _ in range(n):
  a,*b=map(int, input().split())
  A = A & set(b) _ range(n) range n a,*b=map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split *b b A = A & set(b) A A & set(b) A set(b) set b print(len(A)) print len(A) len A m=map(int, input().split()) map(int, input().split()) m n,m=map(int, input().split()) map(int, input().split()) n a,*b=map(int, input().split()) map(int, input().split()) a A=set(range(1, m+1)) set(range(1, m+1)) A A = A & set(b) A & set(b) A
n,m=map(int, input().split())
A=set(range(1, m+1))
for _ in range(n):
  a,*b=map(int, input().split())
  A = A & set(b)
print(len(A))