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

A = [list(map(int, input().split())) for _ in range(N)]

K = []

for i in range(N):

    K.append(A[i][0])

    del A[i][0]

    

ans = A[0]

for i in range(N-1):

    ans = set(ans) & set(A[i+1])



print((len(ans)))

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



ans_list = []

for i in range(N):

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

    for a in A:

        ans_list.append(a)

        

ans = 0

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

    if ans_list.count(i) == N:

        ans += 1

        

print(ans)
N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
K = []
for i in range(N):
    K.append(A[i][0])
    del A[i][0]
ans = A[0]
for i in range(N - 1):
    ans = set(ans) & set(A[i + 1])
print((len(ans)))

N, M = list(map(int, input().split()))
ans_list = []
for i in range(N):
    k, *A = list(map(int, input().split()))
    for a in A:
        ans_list.append(a)
ans = 0
for i in range(1, M + 1):
    if ans_list.count(i) == N:
        ans += 1
print(ans)

-A = [list(map(int, input().split())) for _ in range(N)] -K = [] +ans_list = [] -    K.append(A[i][0]) -    del A[i][0] -ans = A[0] -for i in range(N - 1): -    ans = set(ans) & set(A[i + 1]) -print((len(ans))) +    k, *A = list(map(int, input().split())) +    for a in A: +        ans_list.append(a) +ans = 0 +for i in range(1, M + 1): +    if ans_list.count(i) == N: +        ans += 1 +print(ans)