import numpy as np



(N,M) = list(map(int,input().split()))

B = np.ones(M,dtype=np.int)



for _ in range(N):

    A = np.array(list(map(int,input().split())))[1:]

    for i in range(M):

        if not i+1 in A:

            B[i] = 0

print((B.sum()))
(N,M) = list(map(int,input().split()))

r = int(-1)

for i in range(N):

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

  A.pop(0)

  c = 0

  for a in A:

    c |= (1 << (a-1))

  r &= c



ans = sum([(r>>n)&1 for n in range(M)])

print(ans)
import numpy as np

(N, M) = list(map(int, input().split()))
B = np.ones(M, dtype=np.int)
for _ in range(N):
    A = np.array(list(map(int, input().split())))[1:]
    for i in range(M):
        if not i + 1 in A:
            B[i] = 0
print((B.sum()))

(N, M) = list(map(int, input().split()))
r = int(-1)
for i in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    c = 0
    for a in A:
        c |= 1 << (a - 1)
    r &= c
ans = sum([(r >> n) & 1 for n in range(M)])
print(ans)

-import numpy as np - -B = np.ones(M, dtype=np.int) -for _ in range(N): -    A = np.array(list(map(int, input().split())))[1:] -    for i in range(M): -        if not i + 1 in A: -            B[i] = 0 -print((B.sum())) +r = int(-1) +for i in range(N): +    A = list(map(int, input().split())) +    A.pop(0) +    c = 0 +    for a in A: +        c |= 1 << (a - 1) +    r &= c +ans = sum([(r >> n) & 1 for n in range(M)]) +print(ans)