Katsusando loves omelette rice.
Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.
To prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.
The i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.
Find the number of the foods liked by all the N people.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq N, M \leq 30
 - 1 \leq K_i \leq M
 - 1 \leq A_{ij} \leq M
 - For each i (1 \leq i \leq N), A_{i1}, A_{i2}, ..., A_{iK_i} are distinct.

-----Constraints-----
Input is given from Standard Input in the following format:
N M
K_1 A_{11} A_{12} ... A_{1K_1}
K_2 A_{21} A_{22} ... A_{2K_2}
:
K_N A_{N1} A_{N2} ... A_{NK_N}

-----Output-----
Print the number of the foods liked by all the N people.

-----Sample Input-----
3 4
2 1 3
3 1 2 3
2 3 2

-----Sample Output-----
1

As only the third food is liked by all the three people, 1 should be printed.

Difficulty: introductory

Starter code:

Solutions:
from collections import Counter

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

lis=[]
cnt=0
for i in range(n):
  l=list(map(int,input().split()))
  lis+=l[1:]
  
d=Counter(lis)
for i in d.values():
  if i==n:
    cnt+=1
    
print(cnt)

N, M = list(map(int, input().split()))
l =set([i for i in range(1, M+1)])
for _ in range(N):
  k, *lst = list(map(int, input().split()))
  l = l & set(lst)
  
print((len(l)))


import collections
n,m = list(map(int, input().split()))
l = [list(map(int, input().split())) for l in range(n)]
tmp = []

for i in range(n):
    for a in range(l[i][0]):
        tmp.append(l[i][a + 1])

c = collections.Counter(tmp)

ans = []
for x in list(c.items()):
    if x[1] == n:
        ans.append(x[0])
print((len(ans)))


n,m=map(int,input().split())
l=[0]*m
for i in range(n):
    s=list(map(int,input().split()))
    for j in range(1,len(s)):
        l[s[j]-1]+=1
print(l.count(n))

N,M=map(int,input().split())
h={i for i in range(1,M+1)}
for _ in range(N):
  a=list(map(int,input().split()))
  a=set(a[1:])
  h&=a
print(len(h))

n, m = list(map(int, input().split()))
like = [0]*m

for _ in range(n):
    al = list(map(int, input().split()))
    arr = al[1:]
    for a in arr:
        like[a-1] += 1

print((like.count(n)))


from collections import Counter
from typing import List


def answer(n: int, m: int, kas: List[List[int]]) -> int:
    response = sum((ka[1:] for ka in kas), [])
    result = list(Counter(response).values())
    return result.count(n)


def main():
    n, m = map(int, input().split())
    kas = [list(map(int, input().split())) for _ in range(n)]
    print(answer(n, m, kas))


def __starting_point():
    main()
__starting_point()

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

dic={}

for i in range(n):
    k_list=[int(i) for i in input().split()]
    k=k_list[0]
    a_list=k_list[1:]
    
    for j in a_list:
        if j in dic:
            dic[j]+=1
        else:
            dic[j]=1
            
value_list=list(dic.values())
ans=value_list.count(n)

print(ans)

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

s = 0
for i in range(1,m+1):
    s |= 1 << i


for i in range(n):
    a = list(map(int, input().split()))
    a = list(a)
    t = 0
    for j in range(1, len(a)):
        t |= 1 << a[j]
    s &= t


ans = 0
for i in range(1,m+1):
    if (s & (1<<i)) != 0:
        ans += 1

print(ans)


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

N,M=map(int,input().split())
l=[list(map(int,input().split())) for i in range(N)]

ans = [0]*(M+1)
for i in range(N):
	for j in range(l[i][0]):
		ans[(l[i][j+1])] += 1

print(ans.count(N))

N, M = map(int, input().split())
S = set(range(1, M+1))
for _ in range(N):
  l = list(map(int, input().split()))
  l.remove(l[0])
  s = set(l)
  S = S & s
print(len(S))

n, m = [int(i) for i in input().split()]
list_a = [[s for s in input().split()] for i in range(0, n)]
list_ans = [str(s) for s in range(1, m + 1)]
for i in range(0, n):
    for j in range(0, m):
        if list_ans[j] not in list_a[i][1:]:
            list_ans[j] = '0'
print(len([s for s in list_ans if s != '0']))

N, M = list(map(int, input().split()))
t = [0 for i in range(M+1)]
for i in range(N):
  A = list(map(int, input().split()))
  for j in range(1, A[0]+1):
    t[ A[j] ] += 1
ans = 0
for i in t:
  if i == N:
    ans += 1
print(ans)


#!/usr/bin/env python3

def main():
    n, m = list(map(int, input().split()))
    k, *a = list(map(int, input().split()))
    ans = set(a)
    for i in range(n - 1):
        k, *a = list(map(int, input().split()))
        ans = ans & set(a)
    print((len(ans)))


def __starting_point():
    main()

__starting_point()

N,M = map(int,input().split())
foods = [0]*M

for i in range(N):
  KA = list(map(int,input().split()))
  
  for a in KA[1:]:
    foods[a-1] += 1
  
cnt = 0
for j in foods:
  if j == N:
    cnt += 1
    
print(cnt)

N, M = map(int, input().split())
  
l = [0]*M
for _ in range(N):
  A = list(map(int, input().split()))
  for j in range(A[0]):
    l[A[j+1]-1] += 1

# lの要素でNである個数を出力
print(l.count(N))

N, M = map(int, input().split())
l = []
for i in range(N):
  l.append(list(map(int, input().split())))
  
ans = [0] * (M+1)
for i in range(N):
  n = l[i]
  for j in range(1, n[0]+1):
    ans[n[j]] += 1
    
cnt = 0
for i in range(M+1):
  if ans[i] == N:
    cnt += 1
print(cnt)

N,M=map(int,input().split())
b=[]
s=[0]*M
for i in range(N):
    a=list(map(int,input().split()))
    del a[0]
    a.sort()
    b.append(a)
for i in range(N):
    for j in range(len(b[i])):
        s[b[i][j]-1]+=1
print(s.count(N))

n, m = list(map(int, input().split()))
if n == 1:
    a = list(map(int, input().split()))
    print((a[0]))
else:
    A = list(map(int, input().split()))
    ans = set(A[1:])

    for _ in range(n-1):
        A = list(map(int, input().split()))
        ans = ans & set(A[1:])

    print((len(ans)))


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

ans = set(list(map(int, input().split()))[1:])
for i in range(N - 1):
    line = set(list(map(int, input().split()))[1:])
    ans = ans & line
print((len(ans)))


N,M=map(int, input().split())
ans=set(list(map(int, input().split()))[1:])

for i in range(N-1):
	temp=set(list(map(int, input().split()))[1:])
	ans=ans&temp

print(len(ans))

n,m = map(int,input().split())
al = []
kazu = []
for i in range(n):
  ka = list(map(str,input().split()))
  for j in range(int(ka[0])):
    al.append(ka[j+1])
from collections import Counter
l = Counter(al)
for i in range(m):
  kazu.append(l[str(i+1)])
print(kazu.count(n))

N , M = list(map(int,input().split()))
con = 0
like = 0
List = []
for i in range(1,N+1):
  L = list(map(int,input().split()))
  for a in range(L[0]):
    b = L[a + 1]
    List.append(b)
for j in range(1,M + 1):
  con = 0
  for k in List:
    if k == j:
      con += 1
  if con == N:
    like += 1   
print(like)


N, M = map(int, input().split())
A = []
for _ in range(N):
  A.append(list(map(int, input().split())))
  
l = [0]*M
for i in range(N):
  num = A[i][0]
  for j in range(num):
    l[A[i][j+1]-1] += 1

# lの要素でNである個数を出力
print(l.count(N))

a, b = map(int, input().split())
L = list(map(str, input().split()))
L.pop(0)
for i in range(a-1):
  c = list(map(str, input().split()))
  c.pop(0)
  L = list(set(L) & set(c))
print(len(L))

n, m = map(int, input().split())
s = set(range(1, 1+m))
for _ in range(n):
  k, *a = map(int, input().split())
  s &= set(a)
print(len(s))

n, m = map(int, input().split())
l = [0]*m
for _ in range(n):
    k, *a = map(int, input().split())
    for i in a:
        l[i-1] += 1
print(l.count(n))

n,m = map(int,input().split())
 
food = [0]*(m+1)
for i in range(n):
    l = [int(x) for x in input().split()]

    l = set(l[1:])

    for x in l:
        food[x] += 1
 
ans = food.count(n)
print(ans)

n, m = list(map(int, input().split()))
nums = [0 for num in range(m)] 
for i in range(n):
    k = [int(s) for s in input().split()]
    for j in range(1, len(k)):
        nums[k[j] - 1] += 1
print((nums.count(n)))


N, M = map(int, input().split())
res = [0]*M

for i in range(N):
    K, *A = map(int, input().split())
    for j in range(K):
        res[A[j]-1] += 1

cnt = 0
for i in range(M):
    cnt += (res[i] == N)

print(cnt)

N, M = map(int, input().split())
ans = set()
for i in range(N):
    A = list(map(int, input().split()))
    a = set(A[1:])
    if not ans:
        ans = a
    else:
        ans = ans & a
print(len(ans))

N,M = map(int,input().split())
foods = [0]*M
 
for i in range(N):
  KA = list(map(int,input().split()))
  
  for a in KA[1:]:
    foods[a-1] += 1
  
cnt = 0
for j in foods:
  if j == N:
    cnt += 1
    
print(cnt)

N, M = map(int, input().split())
S = set([x for x in range(1,M+1)])

for i in range(N):
 
  A = list(map(int, input().split()))
  B = set(A[1:])
 
  S = S & B
print(len(S))

n, m = list(map(int, input().split()))
KA =[list(map(int, input().split())) for _ in range(n)]

cnt = [0]*m
for ka in KA:
  for a in ka[1:]:
    cnt[a-1] += 1

ans = 0
for i in cnt:
  if i == n:
    ans += 1
print(ans)


n, m = map(int, input().split())
c = [0]*m

for i in range(n):
    a = list(map(int, input().split()))
    for j in range(1, a[0]+1):
        c[a[j]-1] += 1
print(c.count(n))

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,M = MI()
X = LI()
ANS = set(X[1:])
for i in range(N-1):
    X = LI()
    ANS &= set(X[1:])

print((len(ANS)))


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

foods = []
for i in range(n):
    foods.append(list(map(int, input().split())))

if len(foods) == 1:
    print((len(foods[0])-1))
else:
    ans = 0
    for i in foods[0][1:len(foods[0])]:
        cnt = 0
        for j in range(1, len(foods)):
            if i in foods[j][1:len(foods[j])]:
                cnt += 1
                if cnt == len(foods) - 1:
                    ans += 1

    print(ans)


n, m = map(int,input().split())
k = [list(map(int,input().split())) for _ in range(n)]
l = [0 for i in range(m)]
count = 0
for i in k:
    for j in i[1:]:
        l[j-1] += 1
for i in l:
    if i == n:
        count += 1
print(count)

n, m = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
f = x[0]
g = set(f[1:])
for i in range(1, n):
    f = x[i]
    g = g & set(f[1:])
print(len(g))

# ABC118
# B Foods Loved by Everyone 答え見た
# N人、M種類
# iの人はAikだけ好き
# M種類の中にN人全員が好きなものがあるかチェック
# N人分のAikリストを積集合する
import collections
import itertools
N, M = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
for x in A:  # A[0]=kは余計なので削除
    n = x.pop(0)
A = list(itertools.chain.from_iterable(A))
C = collections.Counter(A)
ct = 0
for i in range(1,M+1):
    if C[i] == N:
        ct += 1
print(ct)


N,M = list(map(int,input().split()))
d = {i:0 for i in range(1,M+1)}

for _ in range(N):
  L = list(map(int,input().split()))[1:]
  for i in L:
    d[i] += 1
    
cnt = sum([1 for k,v in list(d.items()) if v == N])
print(cnt)


N ,M = map(int,input().split())
K = []
for i in range(N):
    K.append(list(map(int,input().split())))

K_list = []
for x in range(N):
    K[x].remove(K[x][0])
    K_list.extend(K[x])

cnt = 0
for j in range(1, M + 1):
    if K_list.count(j) == N:
        cnt += 1

print(cnt)

N, M = [int(x) for x in input().split()]
Like = [0 for _ in range(M+1)]
for i in range(N):
  KA = [int(x) for x in input().split()]
  for j in range(1, KA[0]+1):
    Like[KA[j]] += 1
ans = 0
for i in range(M+1):
  if(Like[i]==N):
    ans += 1
print(ans)

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

for i in range(n):
    a = list(map(int, input().split()))
    if i == 0:
        answer = set(a[1:])
    else:
        answer = answer & set(a[1:])

print(len(answer))

n , m = map(int, input().split())
e = 0
d = []
for i in range(1, n + 1):
  l = list(map(int, input().split()))
  for a in range(l[0]):
    b = l[a + 1]
    d.append(b)
for j in range(1, m + 1):
  c = 0
  for k in d:
    if k == j:
      c += 1
  if c == n:
    e += 1
print(e)

N,M=list(map(int,input().split()))
ka=[[int(x) for x in input().split()] for _ in range(N)]
K=list()
A=list()
for i in range(N):
  K.append(ka[i][0])
  A.append(ka[i][1:])
ans=[0]*(M+1)
for i in range(N):
  for j in range(K[i]):
    ans[A[i][j]]+=1
cnt=0
for i in range(M+1):
  if ans[i]==N:
    cnt+=1
print(cnt)


n,m = list(map(int, input().split()))
_, *A = list(map(int, input().split()))
food = set(A)
for _ in range(n-1):
    k, *A = list(map(int, input().split()))
    food &= set(A)
print((len(food)))


n,m=map(int, input().split())
ka=[list(map(int, input().split())) for i in range(n)]
cnt=0
for i in range(m+1):
    suki=0
    for j in range(n):
        if i in ka[j][1:]:
            suki+=1
    if suki==n:
        cnt+=1
print(cnt)

n,m = map(int,input().split())
s = set(range(1,m+1))
for i in range(n):
    k,*a = map(int,input().split())
    s &= set(a)
print(len(s))

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

l=[]
for i in range(n):
  p=list(map(int,input().split()))
  for j in range(1,p[0]+1):
    l.append(p[j])

cnt=0

for k in l:
  if l.count(k)==n:
    cnt+=1

print(cnt//n)

N, M = map(int, input().split())
food = []
for i in range(N):
  food.append(list(map(int, input().split())))

like = [0 for i in range(M)]
for i in range(N):
  for j in range(food[i][0]):
    like[food[i][j+1]-1] += 1
print(like.count(N))

n,m = map(int,input().split())
data = [0]*n
for i in range(n):
    data[i] = input().split()
ans = 0
if n == 1:
    print(len(data[0]) - 1)
else:
    for i in range(1,int(data[0][0]) + 1):
        bool = True
        for j in range(1,n):
            if data[0][i] not in data[j][1:]:
                bool = False
        if bool:
            ans += 1
    print(ans)

from collections import Counter


def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n, m = Input()
    data = [Input()[1:] for _ in range(n)]
    d = Counter(num for row in data for num in row)
    print(sum(value == n for value in d.values()))


main()

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

K, *result = map(int, input().split())
result = set(result)
for _ in range(N-1):
    K, *A = map(int, input().split())
    A = set(A)
    result = result & A
    
print(len(result))

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

n,m=map(int,input().split())
ka=[list(map(int,input().split())) for _ in range(n)]

flg = [0] * (m+1)
for i in range(n):
  for j in range(1,ka[i][0]+1):
    food = ka[i][j]
    flg[food] += 1

result = 0
for i in range(m+1):
  if flg[i] == n:
    result += 1
print(result)

#ABC118B
n,m = list(map(int,input().split()))
l = [0]*m
for i in range(n):
    k,*a = list(map(int,input().split()))
    for j in range(k):
        l[a[j]-1]+=1

print((l.count(n)))


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

ans = [0] * m

for i in range(n):
    tmp = list(map(int, input().split()))
    for j in range(len(tmp)):
        if j == 0:
            pass
        else:
            ans[tmp[j] - 1] += 1
print(ans.count(n))

n, m = map(int, input().split())
k_a = [ list(map(int, input().split())) for _ in range(n) ]

ans = {}
for a in k_a:
    for i in a[1:]:
        if i in ans.keys():
            ans[i] += 1
        else:
            ans[i] = 1
print(sum([ 1 for i,v in ans.items() if v == n ]))

n,m =  map(int,input().split())
k = []
cnt = 0

for i in range(n):
    tmp = input().split()
    tmp.pop(0)
    k += tmp

for i in range(m):
    if k.count(str(i+1)) == n:
        cnt += 1

print(cnt)

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

N = a[0]
M = a[1]

ctr = [0 for i in range(M)]


for i in range(N):
    b =  list(map(int,input().split()))

    for j in range(b[0]):
        for k in range(M):
            if b[j+1] == k+1:
                ctr[k] += 1

flag = [N == ctr[j] for j in range(M)]
print(sum(flag))

n,m = map(int, input().split())
line = [0 for i in range(m+1)]
ans = 0
for i in range(n):
  like_list = list(map(int, input().split()))
  for j in range(like_list[0]):
    line[like_list[j+1]] += 1
for i in range(m+1):
  if line[i] == n:
    ans += 1
print(ans)

N, M = map(int, input().split())
  
l = [0]*M
for i in range(N):
  L = list(map(int, input().split()))
  num = L[0]
  A = L[1:]
  for j in range(num):
    l[A[j]-1] += 1

# lの要素でNである個数を出力
print(l.count(N))

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

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

dp = [0]*m

for i in range(n):
    for j in range(ab[i][0]):
        k = ab[i][j+1]
        dp[k-1] +=1
        
print(dp.count(n))

n, m = map(int, input().split())
s = set(range(1, m+1))
for _ in range(n):
    k, *a = map(int, input().split())
    s&=set(a)

print(len(s))

n,m=map(int,input().split())
l = [0]*m
for i in range(n):
    a = list(map(int, input().split()))
    del a[0]
    for i in a:
        l[i-1] +=1
print(l.count(n))

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

a = set(range(1, m + 1))
for _ in range(n):
    k, *aa = map(int, input().split())
    a = a & set(aa)

print(len(a))

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data))


def __starting_point():
    main()
__starting_point()

n, m = list(map(int, input().split()))
like = [0]*m
for _ in range(n):
    al = list(map(int, input().split()))
    k = al[0]
    ai = al[1:]
    for a in ai:
        like[a-1] += 1

print((like.count(n)))


n,m = map(int,input().split())
L = [i for i in range(1,m+1)]
for j in range(n):
    l = list(map(int,input().split()))
    del l[0]
    L = set(l) & set(L)
print(len(L))

import itertools

N, M = map(int, input().split())
L = []
res, cnt = 0, 1

for i in range(N):
    K = list(map(int, input().split()))
    L.append(K[1:])

L = list(itertools.chain.from_iterable(L))
L.sort()
L.append(100)

for i in range(len(L)-1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt == N:
            res += 1
        cnt = 1
    

print(res)

n,m=map(int,input().split())
all=[0 for i in range(m)]
ans=0
for i in range(n):
    p=list(map(int,input().split()))
    last=p[0]+1
    for l in range(1,last):
        all[p[l]-1]+=1
for i in all:
    if i==n:
        ans+=1
print(ans)

import sys

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    KA = [[int(x) for x in input().split()] for _ in range(N)]

    ans = [0] * M

    for ka in KA:
        for a in ka[1:]:
            ans[a - 1] += 1

    print((sum([int(x == N) for x in ans])))


def __starting_point():
    main()

__starting_point()

n, m = list(map(int, input().split()))
like = [0] * m

for i in range(n):
    a = list(map(int, input().split()))[1:]
    for j in a:  like[j-1] += 1

print((sum(i==n for i in like)))


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


n, m = list(map(int, input().split()))
s = set(i for i in range(1,m+1))
for i in range(n):
    k,*a = list(map(int,input().split()))
    s &= set(a)

print((len(s)))


N,M=map(int,input().split())
l=[0]*M
for i in range(N):
    A=list(map(int,input().split()))
    K=A[0]
    A=A[1:]
    for j in range(K):
        l[A[j]-1]+=1
print(l.count(N))

N,M=list(map(int,input().split()))
cnt=[0 for _ in range(M)]
for _ in range(N):
    A=list(map(int,input().split()))
    for j in range(1,A[0]+1):
        cnt[A[j]-1]+=1
print((cnt.count(N)))


n,m = map(int,input().split())
ans = set(range(1,31))
for i in range(n):
  kA = list(map(int,input().split()))
  k = kA[0]
  A = kA[1:]
  ans = ans & set(A)
print(len(ans))

n, m = map(int, input().split())
KA = [list(map(int, input().split())) for _ in range(n)]

ans = [0] * m

for i in range(n):
    A = KA[i][1:]
    for a in A:
        ans[a-1] += 1
        
cnt = 0
for a in ans:
  if a == n:
    cnt += 1
print(cnt)

import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
N = l[0]
M = l[1]
KA = [list(map(int,input().split())) for c in range(N)]

F = [0]*M

for i in range(N):
    for j in range(1,KA[i][0]+1):
        F[KA[i][j]-1]+=1
print(F.count(N))

n, m = map(int, input().split())
dic = {}
ans = 0

for _ in range(n):
  lis = input().split()
  for i in range(1, len(lis)):
    if lis[i] in dic:
      dic[lis[i]] += 1
    else:
      dic[lis[i]] = 1

for v in dic.values():
  if v == n:
    ans += 1

print(ans)

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

A_list = []
for _ in range(N):
    A = list(map(int, input().split()))
    del A[0]
    A_list.extend(A)

ans = 0
for i in range(1, M + 1):
    if A_list.count(i) == N:
        ans += 1

print(ans)

n,m=map(int, input().split())
a=[list(map(int,input().split())) for i in range(n)]
count=0
for i in range(1,m+1):
  check=True
  for j in range(n):
    if i not in a[j][1:]:
      check=False
  if check:
    count+=1
print(count)

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

s = set(range(1, m+1))
for i in range(n):
    k, *a = list(map(int, input().split()))
    s &= set(a)

print((len(s)))


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

import math
import collections
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
ka = [li() for _ in range(n)]

food = [0]*m
for i in range(n):
    for j in range(1,ka[i][0]+1,1):
        food[ka[i][j]-1] += 1
print(food.count(n))

n, m = list(map(int, input().split()))
S = set(range(1, m+1))

for i in range(n):
    k, *a = list(map(int, input().split()))
    S &= set(a)

print((len(S)))


n,m=list(map(int,input().split()))
l=[0]*(m+1)
count=0
for i in range(n):
    k=list(map(int,input().split()))
    for j in range(1,k[0]+1):
        l[k[j]]+=1
for i in range(1,m+1):
    if l[i]==n:
        count+=1
print(count)


N, M = list(map(int, input().split()))
K1 = []
for i in range(N):
    K1.append(list(map(int, input().split())))
    
new_K1 = []
for n in range(N):
    del K1[n][0] 
    new_K1.extend(K1[n])

count = 0
for y in range(1, M + 1):
    if new_K1.count(y) == N:
        count += 1

print(count)


n,m=map(int,input().split())
l=[0 for i in range(m)]
for i in range(n):
  ka=[int(x) for x in input().split()]
  k=ka[0]
  for j in range(1,k+1):
    l[ka[j]-1]+=1

ans=0
for i in l:
  if i==n:
    ans+=1
print(ans)

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

food = [0]*(m+1)
for i in range(n):
    l = [int(x) for x in input().split()]
    l = set(l[1:])
    for x in l:
        food[x] += 1

ans = food.count(n)
print(ans)

import numpy as np
n,m = map(int,input().split())
k = np.zeros(n,dtype=int)
a = np.zeros((n,m),dtype=int)
for i in range(n):
    p = list(map(int, input().split()))
    k[i] = p[0]
    for j in range(1,len(p)):
        a[i][j-1] = p[j]
ans = np.zeros(n+m,dtype=int)
for i in range(n):
    for j in range(m):
        if a[i][j] != 0:
            s = a[i][j]-1
            ans[s] += 1
an = 0
for i in range(n+m):
    if ans[i] == n:
        an += 1
print(an)


# ABC118
# B Foods Loved by Everyone
# N人、M種類
# iの人はAikだけ好き
# M種類の中にN人全員が好きなものがあるかチェック
# N人分のAikリストを積集合する
N, M = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
for x in A:  # A[0]=kは余計なので削除
    n = x.pop(0)
I = set(A[0])  # interesection使うためA[0]をset()
for i in range(1,N):
    # set(a).interesection(b)でaとbの積集合
    I = I.intersection(A[i]) # Iを積集合の結果として、残りのA[i]と比較
print((len(I)))  # 何種類？なのでlen()


n,m=list(map(int,input().split()))
ans = []
for i in range(1, m+1):
  ans.append(i)
ans = set(ans)
for i in range(n):
  a = list(map(int,input().split()))
  del a[0]
  a = set(a)
  ans = ans & a
print((len(ans)))


n,m = map(int, input().split())
k = [list(map(int, input().split())) for i in range(n)]
c = 0
for i in range(1,m+1):
    for j in range(n):
        if i not in k[j][1:]:
            break
    else:
        c+=1
print(c)

# import numpy as np
# import math

# from scipy.special import perm : perm(n, r, exact=True)
# from scipy.special import comb : comb(n, r, exact=True)

# import itertools
# for v in itertools.combinations(L, n):M.append(list(v))

# from numba import njit
# @njit('f8(i8,i8,i8,i8,f8[:,:,:])', cache=True)


""" Definitions  """

def lcm(a, b):
    return a*b//math.gcd(a, b)

MOD = 10**9+7

# ============================================================

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

L = [0]*(m+1)

for i in range(n):
    A = list(map(int, input().split()))
    for k in range(1, A[0]+1):
        L[A[k]] += 1
print((L.count(n)))