from collections import Counter

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

food_arr = []

total = 0

for i in range(n):

   food_arr += list(map(int, input().split()[1:]))

    

counter = Counter(food_arr)

for key, value in list(counter.items()):

  if value == n:

    total += 1

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

se = set(range(1,M+1))

for _ in range(N):

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

  se &= set(A)

  

print((len(se)))  
from collections import Counter

n, m = list(map(int, input().split()))
food_arr = []
total = 0
for i in range(n):
    food_arr += list(map(int, input().split()[1:]))
counter = Counter(food_arr)
for key, value in list(counter.items()):
    if value == n:
        total += 1
print(total)

N, M = list(map(int, input().split()))
se = set(range(1, M + 1))
for _ in range(N):
    k, *A = list(map(int, input().split()))
    se &= set(A)
print((len(se)))

-from collections import Counter - -n, m = list(map(int, input().split())) -food_arr = [] -total = 0 -for i in range(n): -    food_arr += list(map(int, input().split()[1:])) -counter = Counter(food_arr) -for key, value in list(counter.items()): -    if value == n: -        total += 1 -print(total) +N, M = list(map(int, input().split())) +se = set(range(1, M + 1)) +for _ in range(N): +    k, *A = list(map(int, input().split())) +    se &= set(A) +print((len(se)))