n,m=list(map(int,input().split()))

S=set(range(1,m+1))

for i in range(n):

    K,*A=list(map(int,input().split()))

    S&=set(A)

print((len(S)))
n, m = list(map(int, input().split()))



l = []

for i in range(n):

  a = [int(x) for x in input().split()]

  for j in range(1, a[0] + 1):

    l.append(a[j])



ans = 0

for i in range(m + 1):

  if l.count(i) == n:

    ans += 1



print(ans)
n, m = list(map(int, input().split()))
S = set(range(1, m + 1))
for i in range(n):
    K, *A = list(map(int, input().split()))
    S &= set(A)
print((len(S)))

n, m = list(map(int, input().split()))
l = []
for i in range(n):
    a = [int(x) for x in input().split()]
    for j in range(1, a[0] + 1):
        l.append(a[j])
ans = 0
for i in range(m + 1):
    if l.count(i) == n:
        ans += 1
print(ans)

-S = set(range(1, m + 1)) +l = [] -    K, *A = list(map(int, input().split())) -    S &= set(A) -print((len(S))) +    a = [int(x) for x in input().split()] +    for j in range(1, a[0] + 1): +        l.append(a[j]) +ans = 0 +for i in range(m + 1): +    if l.count(i) == n: +        ans += 1 +print(ans)