import numpy as np



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



like_total = np.zeros(M)

cnt = 0

for _ in range(N):

    l = [v for v in map(int, input().split())]

    #print(l)

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

        like_total[l[i]-1] += 1



#print(like_total, N)

#print(like_total[4], like_total[9], like_total[-1])

ans = len(np.where(like_total==N)[0])



print(ans)

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



like_total = [0]*M

cnt = 0

for _ in range(N):

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

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

        like_total[l[i]-1] += 1



for v in like_total:

    cnt += v==N

print(cnt)

import numpy as np

N, M = list(map(int, input().split()))
like_total = np.zeros(M)
cnt = 0
for _ in range(N):
    l = [v for v in map(int, input().split())]
    # print(l)
    for i in range(1, l[0] + 1, 1):
        like_total[l[i] - 1] += 1
# print(like_total, N)
# print(like_total[4], like_total[9], like_total[-1])
ans = len(np.where(like_total == N)[0])
print(ans)

N, M = list(map(int, input().split()))
like_total = [0] * M
cnt = 0
for _ in range(N):
    l = list(map(int, input().split()))
    for i in range(1, l[0] + 1, 1):
        like_total[l[i] - 1] += 1
for v in like_total:
    cnt += v == N
print(cnt)

-import numpy as np - -like_total = np.zeros(M) +like_total = [0] * M -    l = [v for v in map(int, input().split())] -    # print(l) +    l = list(map(int, input().split())) -# print(like_total, N) -# print(like_total[4], like_total[9], like_total[-1]) -ans = len(np.where(like_total == N)[0]) -print(ans) +for v in like_total: +    cnt += v == N +print(cnt)