n,m = map(int,input().split())
ans = set(range(1,31))
for i in range(n):
  kA = list(map(int,input().split()))
  k = kA[0]
  A = kA[1:]
  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,31)) ans set(range(1,31)) set range(1,31) range 1 31 for i in range(n):
  kA = list(map(int,input().split()))
  k = kA[0]
  A = kA[1:]
  ans = ans & set(A) i range(n) range n kA = list(map(int,input().split())) kA list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k = kA[0] k kA[0] kA 0 A = kA[1:] A kA[1:] kA 1: 1 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 ans = set(range(1,31)) set(range(1,31)) ans kA = list(map(int,input().split())) list(map(int,input().split())) kA ans = ans & set(A) ans & set(A) ans A = kA[1:] kA[1:] A m = map(int,input().split()) map(int,input().split()) m k = kA[0] kA[0] k
n,m = map(int,input().split())
ans = set(range(1,31))
for i in range(n):
  kA = list(map(int,input().split()))
  k = kA[0]
  A = kA[1:]
  ans = ans & set(A)
print(len(ans))