from collections import Counter

n,m = list(map(int,input().split()))

many  =[]

for i in range(n):

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

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

        many.append(a[j])



ans = Counter(many).most_common()

count = 0

for i in range(len(ans)):

    if ans[i][1] == n:

        count += 1



print(count)
n,m = list(map(int,input().split()))

data = [0 for i in range(m)]

for i in range(n):

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

    for x in a:

        data[x-1] += 1

ans = 0

for i in range(m):

    if data[i] == n:

        ans += 1



print(ans)
from collections import Counter

n, m = list(map(int, input().split()))
many = []
for i in range(n):
    a = list(map(int, input().split()))
    for j in range(1, a[0] + 1):
        many.append(a[j])
ans = Counter(many).most_common()
count = 0
for i in range(len(ans)):
    if ans[i][1] == n:
        count += 1
print(count)

n, m = list(map(int, input().split()))
data = [0 for i in range(m)]
for i in range(n):
    k, *a = list(map(int, input().split()))
    for x in a:
        data[x - 1] += 1
ans = 0
for i in range(m):
    if data[i] == n:
        ans += 1
print(ans)

-from collections import Counter - -many = [] +data = [0 for i in range(m)] -    a = list(map(int, input().split())) -    for j in range(1, a[0] + 1): -        many.append(a[j]) -ans = Counter(many).most_common() -count = 0 -for i in range(len(ans)): -    if ans[i][1] == n: -        count += 1 -print(count) +    k, *a = list(map(int, input().split())) +    for x in a: +        data[x - 1] += 1 +ans = 0 +for i in range(m): +    if data[i] == n: +        ans += 1 +print(ans)