N, M = map(int, input().split())
S = set(range(1, M+1))
for _ in range(N):
  l = list(map(int, input().split()))
  l.remove(l[0])
  s = set(l)
  S = S & s
print(len(S)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M S = set(range(1, M+1)) S set(range(1, M+1)) set range(1, M+1) range 1 M+1 M 1 for _ in range(N):
  l = list(map(int, input().split()))
  l.remove(l[0])
  s = set(l)
  S = S & s _ range(N) range N l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split l.remove(l[0]) l.remove l remove l[0] l 0 s = set(l) s set(l) set l S = S & s S S & s S s print(len(S)) print len(S) len S S = S & s S & s S N, M = map(int, input().split()) map(int, input().split()) N S = set(range(1, M+1)) set(range(1, M+1)) S l = list(map(int, input().split())) list(map(int, input().split())) l s = set(l) set(l) s M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
S = set(range(1, M+1))
for _ in range(N):
  l = list(map(int, input().split()))
  l.remove(l[0])
  s = set(l)
  S = S & s
print(len(S))