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

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



A = [flatten for inner in A for flatten in inner[1:]]

#print(A)

import collections

A_cnt = collections.Counter(A)

print((sum([l[1]==N for l in A_cnt.most_common()])))

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

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

s = set(A)

for i in range(N-1):

    _, *B = list(map(int,input().split()))

    s &= set(B)

print((len(s)))
N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
A = [flatten for inner in A for flatten in inner[1:]]
# print(A)
import collections

A_cnt = collections.Counter(A)
print((sum([l[1] == N for l in A_cnt.most_common()])))

N, M = list(map(int, input().split()))
_, *A = list(map(int, input().split()))
s = set(A)
for i in range(N - 1):
    _, *B = list(map(int, input().split()))
    s &= set(B)
print((len(s)))

-A = [list(map(int, input().split())) for _ in range(N)] -A = [flatten for inner in A for flatten in inner[1:]] -# print(A) -import collections - -A_cnt = collections.Counter(A) -print((sum([l[1] == N for l in A_cnt.most_common()]))) +_, *A = list(map(int, input().split())) +s = set(A) +for i in range(N - 1): +    _, *B = list(map(int, input().split())) +    s &= set(B) +print((len(s)))