n,m = map(int, input().split())
c = set(i+1 for i in range(m))
for j in range(n):
  l = list(map(int, input().split()))
  l.remove(l[0])
  c = c&set(l)
print(len(c)) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m c = set(i+1 for i in range(m)) c set(i+1 for i in range(m)) set i+1 i 1 for j in range(n):
  l = list(map(int, input().split()))
  l.remove(l[0])
  c = c&set(l) j 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 c = c&set(l) c c&set(l) c set(l) set l print(len(c)) print len(c) len c c = set(i+1 for i in range(m)) set(i+1 for i in range(m)) c m = map(int, input().split()) map(int, input().split()) m l = list(map(int, input().split())) list(map(int, input().split())) l c = c&set(l) c&set(l) c n,m = map(int, input().split()) map(int, input().split()) n
n,m = map(int, input().split())
c = set(i+1 for i in range(m))
for j in range(n):
  l = list(map(int, input().split()))
  l.remove(l[0])
  c = c&set(l)
print(len(c))