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

nes = []

count = 0

for i in range(N) :

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

    nes.append(li)

favorite = [0] * M

for i in range(N) :

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

        favorite[nes[i][j]-1] += 1

for i in range(M) :

    if favorite[i] == N :

        count+=1

print(count)
#template

def inputlist(): return [int(k) for k in input().split()]

#template

N,M = inputlist()

ans = [0]*(M+1)

c =0

for i in range(N):

    A = inputlist()

    K = A[0]

    Aa = A[1:]

    for j in range(K):

        ans[Aa[j]] +=1

for i in range(1,M+1):

    if ans[i] == N:

        c+=1

print(c)
N, M = list(map(int, input().split()))
nes = []
count = 0
for i in range(N):
    li = list(map(int, input().split()))
    nes.append(li)
favorite = [0] * M
for i in range(N):
    for j in range(1, nes[i][0] + 1):
        favorite[nes[i][j] - 1] += 1
for i in range(M):
    if favorite[i] == N:
        count += 1
print(count)

# template
def inputlist():
    return [int(k) for k in input().split()]


# template
N, M = inputlist()
ans = [0] * (M + 1)
c = 0
for i in range(N):
    A = inputlist()
    K = A[0]
    Aa = A[1:]
    for j in range(K):
        ans[Aa[j]] += 1
for i in range(1, M + 1):
    if ans[i] == N:
        c += 1
print(c)

-N, M = list(map(int, input().split())) -nes = [] -count = 0 +# template +def inputlist(): +    return [int(k) for k in input().split()] + + +# template +N, M = inputlist() +ans = [0] * (M + 1) +c = 0 -    li = list(map(int, input().split())) -    nes.append(li) -favorite = [0] * M -for i in range(N): -    for j in range(1, nes[i][0] + 1): -        favorite[nes[i][j] - 1] += 1 -for i in range(M): -    if favorite[i] == N: -        count += 1 -print(count) +    A = inputlist() +    K = A[0] +    Aa = A[1:] +    for j in range(K): +        ans[Aa[j]] += 1 +for i in range(1, M + 1): +    if ans[i] == N: +        c += 1 +print(c)