Problem:
 Score : 200 points    Problem Statement 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 1 3 4
2 1 3
3 1 2 3
2 3 2      Sample Output 1 1  As only the third food is liked by all the three people, 1 should be printed.       Sample Input 2 5 5
4 2 3 4 5
4 1 3 4 5
4 1 2 4 5
4 1 2 3 5
4 1 2 3 4      Sample Output 2 0  Katsusando's hypothesis turned out to be wrong.       Sample Input 3 1 30
3 5 10 30      Sample Output 3 3

Solution (Python):
n,m=input().split()
n,m=int(n),int(m)

b={}
for i in range(n):
    x=input().split()
    for j in range(int(x[0])):
        if int(x[j+1]) not in b:
            b[int(x[j+1])]=1
        else:
            b[int(x[j+1])]+=1
c=0
for i in b:
    if b[i]==n:
        c+=1
print(c)

Solution (Python):

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

pos_list = []

for i in range(n):
    k, *a = map(int, input().split())
    if i == 0:
        pos_list = a
    else:
        pos_list = [pos for pos in pos_list if pos in a]

print(len(pos_list))

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

tabecol = {}
for n in range(N):
    for tabe in A[n][1:]:
        if tabe in tabecol:
            tabecol[tabe] += 1
        else:
            tabecol[tabe] = 1

print( list(tabecol.values()).count(N) )

Solution (Python):
N,M = map(int,input().split())

ans = 0
i_list = []

for i in range(N):
	tmp_list = list(map(int,input().split()))
	i_list.extend(tmp_list[1:])

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

print(ans)

Solution (Python):
N,M=map(int,input().split())
like=[0]*(M+1)
for _ in range(N):
  arr=list(map(int,input().split()))
  for v in arr[1:]:
    like[v]+=1
print(sum([v==N for v in like]))

Solution (Python):
a,b=map(int,input().split())
c=list(map(int,input().split()))[1:]
for _ in range(a-1):c=set(c)&set(list(map(int,input().split()))[1:])
print(len(c))

Solution (Python):
a,b=map(int,input().split())
c=list(map(int,input().split()))[1:]

for _ in range(a-1):
  
  d=list(map(int,input().split()))[1:]
  
  c=set(c)&set(d)


print(len(c))

Solution (Python):
n,m = map(int,input().split())
ka = list(list(map(int,input().split())) for _ in range(n))

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

answer = 0
for i in range(m):
    if like[i] == n:
        answer += 1

print(answer)

Solution (Python):


n,m = [int(x) for x in input().split()]
print(len(set.intersection(*[set(input().split()[1:]) for _ in range(n)])))

Solution (Python):
n, m = map(int, input().split(' '))
k = list(map(int, input().split(' ')))
result = set(k[1:])
for i in range(1,n):
    s = list(map(int, input().split(' ')))
    a = set(s[1:])
    result &= a
print(len(result))

Solution (Python):
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))

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())
s = []
for _ in range(n):
    k, *a = map(int, input().split())
    s.append(a)
dd = defaultdict(int)
for l in s:
    for k in l:
        dd[k] += 1

print(sum(1 if v == n else 0 for k, v in dd.items()))

Solution (Python):
N,M = list(map(int,input().split()))
K = [input().split() for l in range(N)]

hantei = [0] * 30
count = [0] * 30
for j in range(0,30):
    hantei[j] = j + 1

for i in range(N):
    for j in range(1,int(K[i][0])+1):
        for k in range(0,30):
            if int(K[i][j]) == hantei[k]:
                count[k] += 1

ans = 0
for  k in range(0,30):
    if count[k] == N:
        ans += 1

print(ans)

Solution (Python):
n, m = map(int, input().split())
ml = []
for j in range(m):
    ml.append(j + 1)
r = set(ml)
for i in range(n):
    li = list(map(int, input().split()))
    r = r & set(li[1:])
print(len(r))

Solution (Python):

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

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

count = 0
for i in likes:
    if i == n:
        count += 1

print(count)

Solution (Python):
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))

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

ans = 0
for i in range(1, m+1):
  cnt = 0
  for j in ka:
    if i in j:
      cnt += 1
  if cnt == n:
    ans += 1
print(ans)

Solution (Python):
N,M=map(int,input().split())
Set=set(range(1,M+1))
for i in range(N):
  Set=Set & set(list(map(int,input().split()))[1:])
print(len(Set))

Solution (Python):
n,m=map(int,input().split())
u=set([i for i in range(1,m+1)])
for i in range(n):
    l=list(map(int,input().split()))
    s=set(l[1:])
    u=u&s
print(len(u))

Solution (Python):
n, m = map(int, input().split())
a = []
for i in range(n):
    k = list(map(int, input().split()))
    a.append(k[1:])
cnt = 0
for i in range(1, 31):
    key = 1
    for j in range(n):
        if i not in a[j]:
            key = 0
            break
    if key == 1:
        cnt += 1
print(cnt)

Solution (Python):
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))

Solution (Python):
n, m = map(int, input().split())
m_s = set(range(1,m+1))
for i in range(n):
  K,*A=map(int,input().split())
  m_s = m_s & set(A) 
print(len(m_s))

Solution (Python):
n, m = map(int, input().split())
s = {}
for i in range(n):
    a = set(list(map(int, input().split()))[1:])
    if i == 0:
        s = a
    else:
        s = s & a
print(len(s))

Solution (Python):
n, m = map(int, input().split())

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

Solution (Python):
n,m = map(int,input().split())
k = [list(map(int,input().split())) for i in range(n)]
for i in k:
  i.pop(0)
cnt = [[] for i in range(m)]
for i in range(n):
  for j in range(m):
     cnt[j].append(k[i].count(j+1))
ans = 0
for i in cnt:
  if sum(i) == n:
    ans += 1
print(ans)

Solution (Python):
n,m=map(int,input().split())
menu=[True]*m

for i in range(n):
  amenu=[False]*m 
  a=list(map(int,input().split()))
  a.pop(0)
  for j in range(len(a)):
    amenu[a[j]-1]=True 
    
  for p in range(len(amenu)):
    if amenu[p]==False:
      menu[p]=False

count=0
for i in range(len(menu)):
  count = count + menu[i]

print(count)

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

Solution (Python):
N, M = map(int, input().split())

a = set(str(x) for x in range(1,M+1))
for i in range(N):
  li = list(input().split())
  a = a & set(li[1:])

print (len(a))

Solution (Python):
n,m = map(int,input().split())
A = [0]*(m+1)
ans=0
k = []
a = []
for i in range(n):
    s = list(map(int, input().split()))
    k.append(s[0])
    a.append(s[1:])
    for j in range(s[0]):
        A[s[j+1]] +=1
for i in range(m):
  if A[i+1]==n:
    ans+=1
print(ans)

Solution (Python):
n, m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]

like = [0] * (m+1)

for i in range(n):
    for j in range(1,a[i][0]+1):
        like[a[i][j]] += 1

cnt = 0
for i in range(len(like)):
    if like[i] == n:
        cnt += 1

print(cnt)

Solution (Python):
import sys
input=sys.stdin.readline

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

Solution (Python):
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))

Solution (Python):
N, M = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(N)]

ans = 0
l = sorted(k, key=lambda l: l[0])
small = l[0]
others = l[1:]

for i in small[1:]:
    if all([i in o[1:] for o in others]):
        ans += 1

print(ans)

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

Solution (Python):
n, m = map(int, input().split())
a = []
ans = [i for i in range(1, m+1)]

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



for i in range(n):
    for j in range(1, m+1):
        if j not in a[i] and j in ans:
            ans.remove(j)


print(len(ans))

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

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

Solution (Python):

import collections

N, M = list(map(int, input().split()))
likes = []
for i in range(N):
    x = list(map(int, input().split()))
    _ = x.pop(0)
    likes += x

col = collections.Counter(likes)
count = 0
for k, v in col.items():
    if v == N:
        count += 1

print(count)

Solution (Python):

N, M = list(map(int, input().split()))
base = []
for i in range(N):
    x = list(map(int, input().split()))
    _ = x.pop(0)
    tmp = [0] * M
    for j in x:
        tmp[j-1] = 1

    base.append(tmp)

base = list(map(list, zip(*base)))

count = 0
for x in base:
    if not 0 in x:
        count += 1

print(count)

Solution (Python):
N,M = map(int,input().split())
M = [0]*M
for i in range(N):
    likes = [int(i) for i in input().split()]
    for i in range(1,len(likes)):
        M[likes[i]-1]+=1
count = 0
for item in M:
    if item == N:
        count += 1
print(count)

Solution (Python):
n, m = map(int, input().split())
food = set(i + 1 for i in range(m))
for i in range(n):
    temp = list(map(int, input().split()))
    food &= set(temp[1:])
print(len(food))

Solution (Python):


N, M = map(int, input().split())
k = [None] * N
a = [None] * N
for i in range(N):
    ka = list(map(int, input().split()))
    k[i] = ka[0]
    a[i] = ka[1:]

ans = 0
for i in range(1, M+1):
    count = 0
    for j in range(N):
        if i in a[j]:
            count += 1

    if count >= N:
        ans += 1

print(ans)

Solution (Python):
n,m = map(int, input().split())
ans = list(input().split())
ans = set(ans[1:])
for i in range(n-1):
    b = list(input().split())
    b = set(b[1:])
    ans = ans & b
print(len(ans))

Solution (Python):
N, M = map(int, input().split())
m = [0] * (M + 1)
for _ in range(N):
    k, *a = map(int, input().split())
    for i in a:
        m[i] += 1
ans = 0
for i in m:
    if i == N:
        ans += 1
print(ans)

Solution (Python):
n,m = map(int,input().split())
ka = [list(map(int,input().split())) for i in range(n)]
a = [ka[i][1:] for i in range(n)]
b = []

for i in a:
  for j in range(len(i)):
    b.append(i[j])
c = 0
for i in range(m):
  if b.count(i+1) == n:
    c += 1
print(c)

Solution (Python):
'''
考え方
n行 m列の行列
「全ての行に登場する数字」の種類数を数える

'''

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





k_intersection = range(1,m+1)
for k_row in k_rows:
    
    
    k_intersection = set(k_intersection) & set(k_row[1:])


print(len(k_intersection))

Solution (Python):
n, m = map(int, input().split())
A = []
for i in range(n):
    a = input().split()
    A.extend(a[1:])
words = list(set(A))
result = 0
for j in range(len(words)):
    if A.count(words[j]) == n:
        result += 1
print(result)

Solution (Python):
mp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nM = int(Tmp[1])
 
nF = [ 0 for i in range(nM)]
 
for i in range(nN):
  Tmp = input().rstrip().split(' ')
  nTmpN = int(Tmp[0])
  for j in range(nTmpN):
    nCnt = int(Tmp[j+1]) - 1
    nF[nCnt] += 1

nAns = 0
for i in range(nM):
  nTmpN = nF[i]
  if nTmpN == nN:
    nAns += 1

print(nAns)

Solution (Python):
n,m = map(int, input().split())
ans = list(input().split())
ans = set(ans[1:])
for i in range(n-1):
    b = list(input().split())
    b = set(b[1:])
    ans = ans & b
print(len(ans))

Solution (Python):
"""


     = sys.stdin.readline().rstrip()
     = list(sys.stdin.readline().rstrip())


     = int(sys.stdin.readline())
     = map(int, sys.stdin.readline().split())
     = list(map(int, sys.stdin.readline().split()))
     = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 1000000007

if __name__ == "__main__":
    N, M = map(int, sys.stdin.readline().split())
    like = [0 for _ in range(M)]
    for _ in range(N):
        ans = list(map(int, sys.stdin.readline().split()))
        for a in ans[1::]:
            like[a - 1] += 1

    cnt = 0
    for l in like:
        if l == N:
            cnt += 1

    print(cnt)

Solution (Python):
n,m = map(int,input().split())
menu = [0 for _ in range(m)]
for i in range(n):
  now = list(map(int,input().split()))
  del now[0]
  for x in now:
    menu[x-1] += 1
for j in range(m):
  if menu[j] == n:
    menu[j] = 1
  else:
    menu[j] = 0
print(sum(menu))

Solution (Python):

n, m = (int(_) for _ in input().split())
ans = 0
food = [0 for i in range(m)]
for i in range(n):
    person = [int(_) for _ in input().split()]
    for j in range(1, person[0] + 1):
        food[person[j] - 1] += 1
for f in food:
    if f == n:
        ans += 1

print(ans)

Solution (Python):
N, M = map(int, input().split())
dp = [0]*(M+1)
for _ in range(N):
    l = list(map(int, input().split()))
    for e in l[1:]:
        dp[e] += 1
ans = 0
for e in dp:
    if e == N:
        ans += 1
print(ans)

Solution (Python):



N, M = map(int, input().split(' '))
intersection = None
for _ in range(N):
    k, *a = map(int, input().split(' '))
    if intersection is None:
        intersection = set(a)
    else:
        intersection = intersection & set(a)

print(len(intersection))

Solution (Python):
N,M = map(int, input().split())
a = [input().split() for l in range(N)]
for i in range(len(a)):
    del a[i][0]
x =set(a[0])
for i in range(N-1):
    x = x & set(a[i+1])
print(len(x))

Solution (Python):
n, m = map(int,input().split())
x = [0]*m

for i in range(n):
    ipt = list(map(int,input().split()))
    k = ipt[0]
    a = ipt[1:len(ipt)]
    for j in range(k):
        x[a[j]-1]+=1

print(x.count(n))

Solution (Python):
n, m = map(int, input().split())
foods = set()
tmp = set()

a = list(map(int, input().split()))
for  j in range(1, len(a)):
    foods.add(a[j])

for i in range(n-1): 
    a = list(map(int, input().split()))
    for j in range(1,len(a)):
        tmp.add(a[j])
    foods &= tmp
    tmp.clear()
    
print(len(foods))

Solution (Python):
N, M = map(int, input().split())
KA = [list(map(int, input().split())) for _ in range(N)]

s = set(range(1, M+1))
for k, *A in KA:
  s &= set(A)
print(len(s))

Solution (Python):
def solve():
    N,M = map(int, input().split())
    foods = [0]*M
    for _ in range(N):
        A = map(int, input().split()[1:])
        for idx in A:
            foods[idx-1] += 1
    
    print(sum(food == N for food in foods))
    
solve()

Solution (Python):
n,m = map(int, input().split())
ans = list(input().split())
ans = set(ans[1:])
for i in range(n-1):
    b = list(input().split())
    b = set(b[1:])
    ans = ans & b
print(len(ans))

Solution (Python):
n,m=map(int,input().split())
li=[0 for i in range(m)]

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

print(li.count(n))

Solution (Python):
"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 1000000007

if __name__ == "__main__":
    n,m = map(int, sys.stdin.readline().split())
    l= [list(map(int,list(sys.stdin.readline().split()))) for i in range(n)]
    c=0
    if n ==1:
        print(l[0][0])
    else:
        for i in range(1,m+1):
            flag = 0
            for j in range(n):
                if i not in l[j][1:]:
                    flag = 1
            if flag == 0:
                c+=1
        print(c)

Solution (Python):
n, m = list(map(int, input().split()))
a = [list(map(int, input().split()))[1:] for _ in range(n)]

cnt = 0
for i in range(1, m+1):
    flag = True
    for j in range(len(a)):
        if not i in a[j]:
            flag = False
    if flag:
        cnt += 1

print(cnt)

Solution (Python):
n,m=map(int,input().split())

common=[]

for i in range(n):
    k,*a=list(map(int,input().split()))
    common.extend(a)
print(len([num for num in set(common) if common.count(num)==n] ))

Solution (Python):
import sys

input = sys.stdin.readline

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

arr = [0 for j in range(M)]

for i in range(N):
    line = [int(x) for x in input().split()]
    for j in line[1:]:
        arr[j-1] += 1

print(arr.count(N))

Solution (Python):
N,M = map(int, input().split())
List = []
for i in range(N):
    List.append([int(m) for m in input().split()])

for j in range(N):
    List[j].remove(List[j][0])

ans = 0
for k in range(len(List[0])):
    num = 0
    for l in range(1,N):
        if List[0][k] in List[l]:
            num += 1
        else:
            break
    if num == N-1:
        ans += 1

print(ans)

Solution (Python):
n, m = map(int,input().split())
set1 = set([i for i in range(1,m+1)])
for i in range(n):
    k,a = input().split(None,1)
    a = list(map(int,a.split()))
    a = set(a)
    set1 = set1 & a
print(len(set1))

Solution (Python):
n, m = list(map(int,input().split()))
k = [list(map(int,input().split())) for i in range(n)]

dic = {}
for i in range(n):
    for j in range(1, k[i][0]+1):
        if k[i][j] in dic:
            dic[k[i][j]] += 1
        else:
            dic[k[i][j]] = 1

ans = 0
for i in dic.values():
    if n == i:
        ans += 1
print(ans)

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

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

Solution (Python):
nm = list(map(int, input().split(' ')))
n = nm[0]
m = nm[1]
backet = [0 for _ in range(m)]
for _ in range(n):
    likes = list(map(int, input().split(' ')))[1:]
    for like in likes:
        backet[like - 1] += 1
res = backet.count(n)
print(res)

Solution (Python):
n, m  = map(int, input().split())
cnt = [0]*m
for i in range(n):
    _ , *a_lis = list(map(int, input().split()))
    for a in a_lis:
        cnt[a-1] += 1
ans = 0
for j in cnt:
    if j == n:
        ans += 1
print(ans)

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

Solution (Python):
import numpy as np

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

d = {}
for i in range(n):
    arr = list(map(int,input().split()))
    for j in range(1,arr[0]+1):
        if not arr[j] in d:
            d[arr[j]] = 1
        else:
            d[arr[j]] += 1

ans = 0

for k in d.keys():
    if d[k] == n:
        ans += 1


print(ans)

Solution (Python):
n,m = map(int, input().split())

l = [0]*m

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

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

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

Solution (Python):
I=lambda:input().split()
n,m=I();s=set(I()[1:])
for _ in[0]*(int(n)-1):s&=set(I()[1:])
print(len(s))

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

Solution (Python):


import sys
import itertools

def resolve():
    N, M = map(int, input().split())
    arr = [0] * (M+1)
    for i in range(N):
        tmp = list(map(int, input().split()))
        for j in range(1, tmp[0]+1):
            arr[tmp[j]] += 1
    ans = 0
    for e in arr:
        if e == N:
            ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()

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

Solution (Python):
l = [int(i) for i in input().split(" ")]
n = l[0]
m = l[1]
foods = set(range(1,m+1))

for i in range(n):
    i_like_list = [int(i) for i in input().split(" ")[1:]]
    i_like_set = set(i_like_list)
    foods = foods & i_like_set
print(len(foods))

Solution (Python):
a, b = map(int, input().split())
c = {i + 1: 0 for i in range(b)}
for i in range(a):
    d = list(map(int, input().split()))
    for j in range(1, len(d)):
        c[d[j]] += 1
d = 0
for k in c.keys():
    if c[k] == a:
        d += 1
print(d)

Solution (Python):
N,M = map(int,input().split())
count = [0] * M
for i in range(N):
    Food = list(map(int,input().split()))
    for j in range(1,len(Food)):
        count[Food[j]-1] += 1

ans = 0
for i in range(M):
    if count[i] == N:
        ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split())
cnt = [0] * m
for _ in range(n):
  _, *a = map(int,input().split())
  for ai in a:
    cnt[ai-1] += 1
sum_ = 0
for c in cnt:
  if c == n:
    sum_ += 1
print(sum_)

Solution (Python):

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

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

print(len(s))

Solution (Python):
N, M = map(int, input().split())
K = [0] * N 
A = [0] * N 
KA = [0] * N
for i in range(N):
    KA[i] = list(map(int, input().split()))
    K[i] = KA[i][0]
    A[i] = KA[i][1:]

count = [0] * M 

for i in range(N):
    for j in range(K[i]):
        tmp = A[i][j]
        count[tmp-1] += 1

print(count.count(N))

Solution (Python):
import collections

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

a = []
for i in range(N):
    tmp = list(map(int, input().split()))
    a += tmp[1:]
    
c = collections.Counter(a)

ans = 0

for val in c.values():
  if val== N:
    ans += 1

print(ans)

Solution (Python):
n, m = map(int, input().split())
cnt = [0] * m
for _ in range(n):
    k = list(map(int, input().split()))
    for i in range(1, len(k)):
        cnt[k[i]-1] += 1
print(cnt.count(n))

Solution (Python):
n,t=map(int,input().split())
x=list(list(map(int,input().split())) for _ in range(n))

from itertools import chain

y=[]

for i in range(n):
	y.append(x[i][1:])

z=list(chain.from_iterable(y))
v=list(set(z))

cnt=0
for i in range(len(v)):
	if z.count(v[i])==n:
		cnt+=1

print(cnt)

Solution (Python):
n, m = map(int, input().split())
ans = [1] * m
for i in range(n):
    KA = list(map(int, input().split()))
    for j in range(m):
        if not(j+1 in KA[1:]):
            ans[j] = 0

print(sum(ans))

Solution (Python):
N, M = list(map(int, input().split()))
L = [0]*M
for n in range(N):
    KA = list(map(int, input().split()))
    for a in KA[1:]:
        L[a-1]+=1

print(L.count(N))

Solution (Python):
people, foods = map(int, input().split(' '))
ls = []
for p in range(0, people):
    ls.append(set(x for i, x in enumerate(list(map(int, input().split(' ')))) if i > 0))

populer = ls[0]
for l in ls:
    populer = populer & l

print(len(populer))

Solution (Python):
n,m=map(int,input().split())

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

for i in range(1,m+1):
    if cnt[i] == n:
      res += 1
print(res)

Solution (Python):
n, m = map(int, input().split())
fav = set(range(1, m + 1))

for _ in range(n):
    a = list(map(int, input().split()))[1:]
    fav = fav.intersection(a)

print(len(fav))

Solution (Python):
n, m = map(int, input().split())
fav = [1] * m

for _ in range(n):
    a = list(map(int, input().split()))[1:]
    for i in range(m):
        fav[i] &= (i + 1 in a)

print(sum(fav))

Solution (Python):
n,m=map(int,input().split())
s = set(range(1,m+1))
for i in range(n):
  a=[int(x) for x in input().split()][1:]
  a=set(a)
  s &= a
print(len(s))

Solution (Python):


def main():
    A,B = map(int,input().split())
    
    originalList = set(list(map(int,input().split()))[1:])
    for i in range(A-1):
        list1=set(list(map(int,input().split()))[1:])
        originalList = originalList & list1

    print(len(originalList))


if __name__== "__main__":
    main()

Solution (Python):
N,M = map(int,input().split())

a = [0] * M
for i in range(N):
	x = list(map(int,input().split()))
	for j in range(1,len(x)):
			a[x[j]-1] += 1

print(a.count(N))

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

ans = 0
for i in range(M):
    if cnt[i]==N:
        ans += 1
        
print(ans)

Solution (Python):
n,m=map(int, input().split())
cnt = [0]*m
for i in range(n):
    like = list(map(int, input().split()))
    k = like.pop(0)
    for j in like:
        cnt[j-1] += 1

all_like=0
for _ in cnt:
    if _ == n:
        all_like += 1
print(all_like)

Solution (Python):
n, m = map(int, input().split())

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

ans = 0
for i in range(1, m+1):
    ans += 1
    for j in range(n):
        if i not in a[j][1:]:
            ans -= 1
            break
print(ans)

Solution (Python):
import collections as co
n,m=map(int,input().split())
l=[]
for i in range(n):
    j,*k=map(int,input().split())
    l.extend(k)
count_num=0
for p,q in co.Counter(l).items():
    if q==n:count_num+=1
print(count_num)

Solution (Python):
N, M = [int(x) for x in input().split()]

k = [0] * (M + 1)
for i in range(N):
    a = [int(x) for x in input().split()]
    del a[0]
    for j in a:
        k[j] += 1
print(k.count(N))

Solution (Python):
N, M = [int(x) for x in input().split()]

k = [0] * (M + 1)
for i in range(N):
    a = [int(x) for x in input().split()]
    del a[0]
    for j in a:
        k[j] += 1
print(k.count(N))

Solution (Python):
n, m  = map(int, input().split())

li = [list(map(int, input().split()))[1:] for _ in range(n)]
ans = 0
for i in range(1, m+1):
    tf = True
    for j in li:
        if i not in j:
            tf = False
            break
    if tf:
        ans += 1

print(ans)

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

Solution (Python):
n, m = map(int, input().split())

ans = set(range(1,m+1))

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

print(len(ans))

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

Solution (Python):
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    likes = [string_to_int(i) for i in inputs]
    everyone_likes = {n for n in range(1, M+1)}

    for l in likes:
        like_set = set()
        for i, f in enumerate(l):
            if i == 0:
                continue
            like_set.add(f)

        everyone_likes = everyone_likes & like_set
    return len(everyone_likes)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(N))
    print(ret)

Solution (Python):
n, m = map(int, input().split(" "))
ks = [set(list(map(int, input().split(" ")))[1:]) for i in range(n)]
ans = set.intersection(*ks)
print(len(ans))

Solution (Python):
N, M = map(int, input().split())
foods = [0]*(M+1)

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

Solution (Python):
N, M = map(int, input().split())
ans = {i for i in range(1, M+1)}
for i in range(N):
    tmp = list(map(int, input().split()))
    K, A = tmp[0], tmp[1:]
    ans = ans.intersection(set(A))
print(len(ans))

Solution (Python):

from collections import Counter

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

C_total = Counter()
for i in range(n):
    A = input().split(' ')
    del A[0]
    C = Counter(A)
    C_total += C

count = 0
for val in C_total.values():
    if val == n:
        count += 1
print(count)

Solution (Python):
n,m=map(int,input().split())
info=[]
for i in range(n):
    info.append(list(map(int,input().split())))
common=[info[0][i] for i in range(1,info[0][0]+1)] 
for i in range(1,n): 
    data=[info[i][j] for j in range(1,info[i][0]+1)]
    common=set(common) & set(data)
print(len(common))

Solution (Python):
n,m = map(int,input().split())
ka = [list(map(int,input().split())) for _ in range(n)]
a = [i[1:] for i in ka]

mcount = [0]*(m+1)
for mi in range(1,m+1):
  for ai in a:
    if mi in ai:
      mcount[mi] += 1
print(mcount.count(n))

Solution (Python):
a, b = map(int, input().split())
c = [0] * b
for i in range(a):
    d = list(map(int, input().split()))
    for j in range(1, len(d)):
        c[d[j]-1] += 1
print(sum(1 if c[i] == a else 0 for i in range(b)))

Solution (Python):
N, M = map(int, input().split())
foods = []
for i in range(0, M):
	foods.append(True)
for i in range(0, N):
	inpt = list(map(int, input().split()))
	lst = []
	for j in range(0, M):
		lst.append(False)
	for j in range(0, inpt[0]):
		lst[inpt[1:][j]-1] = True
	for j in range(0, M):
		foods[j] = foods[j] and lst[j]
cnt = 0
for i in range(0, M):
	if foods[i]:
		cnt += 1
print(cnt)