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 = map(int, input().split())
A = []
K = []
for i in range(N):
	k, *A_i = map(int, input().split())
	K.append(k)
	A.append(A_i)
cnt = 0
for i in range(M):
	flg = 0
	for j in range(N):
		if not i + 1 in A[j]:
			flg = 1
	if flg == 1:
		continue
	cnt += 1
print(cnt)

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())
cand = defaultdict()
for i in range(n):
    x = list(map(int, input().split()))
    for j in range(1, x[0] + 1):
        if x[j] in cand.keys():
            cand[x[j]] += 1
        else:
            cand[x[j]] = 1
count = 0
for index, key in enumerate(cand):
    if cand[key] == n:
        count += 1
print(count)

Solution (Python):
n,m = map(int, input().split()) 
 
counter = []
ans = 0
for i in range(m):
  counter.append(0)
 
for i in range(n):
  ls = list(map(int, input().split()))
  kazu = ls[0]
  for i in range(1, kazu+1):
    num = counter[ls[i] - 1]
    counter[ls[i]-1] = num + 1
for i in range(m):
  if counter[i] == n:
    ans += 1
print(ans)

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

Solution (Python):
n, m = map(int, input().split())
lis = []
for i in range(n):
  lis += input().split()[1:]
  
import collections as cl
dic = cl.Counter(lis)
counter = 0
for num in dic.values():
  if num == n:
    counter += 1
print(counter)

Solution (Python):
n, m = map(int, input().split())
b = []
a = [b.extend(list(map(int, input().split()))[1::]) for _ in range(n)]
num = 0
for i in range(m):
    if b.count(i + 1) == n:
        num += 1

print(num)

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

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

s = set(A[0])
for i in range(1, N):
    s = s & set(A[i])
print(len(s))

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

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

Solution (Python):
n,m=map(int,input().split())
k=[]
a=[input().split()for _ in range(n)]
a.sort()
for i in range(n):
  k.append(a[i].pop(0))

ans=0
count=1

for j in range(int(k[0])):
  for h in range(n-1):
    if a[0][j] in a[h+1]:
      count+=1
  if count==n:
    ans+=1
  count=1

print(ans)

Solution (Python):
h,m=map(int,input().split())
l=[0]*(m+1)
for i in range(h):
  a,*b=map(int,input().split())
  for f in b:
    l[f]+=1
ls=sorted(l,reverse=True)
asd=1
fg=0
while True:
  de=ls.pop(0)
  if de==h:
    fg+=1
  else:break
print(fg)

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

li=[]
for i in range(n):
  temp=list(map(int,input().split()))
  del temp[0]
  li.append(temp)

for i in(mlist):
  judge=0
  for x in(li):
    if i not in x:
      judge=1
  if judge==0:
    ans+=1
print(ans)

Solution (Python):
N, M = map(int, input().split())
s = set(range(1, M+1))
for i in range(N):
  As = list(map(int, input().split()))
  K = As.pop(0)
  s = s&set(As)
r = len(s)
print(r)

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

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

Solution (Python):
n,m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(n)]
dic = {x:0 for x in range(1,m+1)}
ans = 0
for i in range(n):
  for j in range(1, k[i][0] + 1):
    dic[k[i][j]] += 1

for a,b in dic.items():
  if b == n:
    ans += 1
print(ans)

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

food =[0]*(m+1)

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

print(food.count(n))

Solution (Python):
import numpy as np

N, M = map(int, input().split())
foods = np.zeros(M)
for i in range(N):
    a = list(map(int, input().split()))
    K = a[0]
    a = a[1:]
    for k in range(K):
      foods[a[k]-1] += 1

ans = np.count_nonzero(foods == N)
print(ans)

Solution (Python):
import collections

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

counter = collections.Counter()
for _ in range(n):
    k, *la = map(int, input().split())
    for x in la:
        counter[x] += 1
res = 0
for x in counter.values():
    if x == n:
        res += 1
print(res)

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

for i in range(n):
  for food in list(map(int, input().split()))[1:]:
    likes[food] += 1
print(len(list(filter(lambda x: x==n, likes))))

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

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

K, *A_row_first = map(int, input().split())
set_A           = set(A_row_first)

for _ in range(N-1):

    K, *A_row = map(int, input().split())
    set_A     = set_A & set(A_row)

print(len(set_A))

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

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

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

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

Solution (Python):
import numpy as np

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

tastes = np.zeros((n, m), dtype=np.int8)
for i in range(n):
    ka = list(map(int, input().split()))
    for j in range(ka[0]):
        
        tastes[i][ka[j + 1] - 1] = 1
    
    
    
    




score = np.sum(np.sum(tastes == 1, axis=0) == n)
print(score)

Solution (Python):
N,M  = map(int,input().split())
d = {}
for _ in range(N):
    tmp = list(map(int,input().split()))
    for i in range(1, len(tmp)):
        if tmp[i] not in d:
            d[tmp[i]] = 0
        d[tmp[i]] += 1
ans = 0
for v in d.values():
    if v == N:
        ans += 1
print(ans)

Solution (Python):
N,M=map(int, input().split())
print(len(set.intersection(*[set(input().split()[1:]) for _ in range(N)])))

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

Solution (Python):
N,M=map(int, input().split())
K,*A=map(int, input().split())
s=set(A)
for i in range(1,N):
  K,*A=map(int, input().split())
  s=s&set(A)
print(len(s))

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

Solution (Python):
N, M = map(int, input().split())
el = list(range(1, M + 1))
for _ in range(N):
    A = [int(x) for x in input().split()[1:]]
    for i, f in enumerate(el):
        if f not in A:
            el[i] = -1
print(len([x for x in el if x >= 1]))

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())
ans_set = {i for i in range(1,m+1)}
for i in range(n):
  a = list(map(int,input().split()))
  del a[0]
  a_set = set(a)
  ans_set = ans_set & a_set
print(len(ans_set))

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

for _ in range(N):
    lst = list(map(int, input().split()))
    for i in range(lst[0]):
        cnt[lst[i + 1] - 1] += 1

print(cnt.count(N))

Solution (Python):
n,m = map(int,input().split())
A = list(map(int,input().split()))
leng = A[0]
nums = set(A[1:leng+1])

for i in range(n-1):
  B = list(map(int,input().split()))
  leng = B[0]
  new = set(B[1:leng+1])
  nums = nums & new 
print(len(nums))

Solution (Python):
"""
【ABC118】
B_Foods_Loved_by_Everyone



import sys


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def IS(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def SS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()

lst = []
cnt = 0
N, M = IS()
for i in range(N):
    lst += (LI()[1:])
for i in range(1, M+1):
    if lst.count(i) == N:
        cnt += 1
print(cnt)

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

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

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

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

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

Solution (Python):
N, M = map(int, input().split())
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
L = [0 for i in range(M)]
for a in A:
  for i in range(1, len(a)):
    L[a[i]-1]+=1
print(len([i for i in L if i == N]))

Solution (Python):
n, m = map(int, input().split())
like = set()
for _ in range(n):
    k, *a = map(int, input().split())
    if like:
        like &= set(a)
    else:
        like = set(a)
print(len(like))

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

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

print(len(ans))

Solution (Python):
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
ALL = sum(list(map(lambda x: x[1:], L)), [])

ans = 0
for i in set(ALL):
    if ALL.count(i) is N:
        ans += 1

print(ans)

Solution (Python):
N,M = map(int, input().split())
A = [1]*M
for _ in range(N):
    C = list(map(int, input().split()))
    B = C[1:]
    for i in range(1,M+1):
        if not i in B:
            A[i-1] = 0
print(sum(A))

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):
import collections
N,M=map(int,input().split())

counter=collections.defaultdict(int)
for _ in range(N):
  text = list(input().split())
  for x in text[1:]:
    counter[x]+=1
ans=0
for x in counter:
  if counter[x]== N:
    ans+=1
print(ans)

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

Solution (Python):



N, M = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(N)]
dic = set(a[0][1::])
tmp = {}

for i in range(1, N):
    tmp = set(a[i][1::])
    dic = dic & tmp
print(len(dic))

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):
import collections
n,m=map(int,input().split())
A=[]
for i in range(n):
    a=list(map(int,input().split()))
    for k in range(a[0]):
        A.append(a[k+1])
B=collections.Counter(A)
c=0
for j in B.keys():
    if B[j]==n:
        c+=1
print(c)

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

for i in range(n):
  DD = list(map(int, input().split()))
  DD.pop(0)
  DB.append(DD)

fav = set(DB[0])
for i in range(n):
  fav = fav & set(DB[i])
print(len(fav))

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

Aset = list(set(Alist)) 
ans = 0

for i in range(len(Aset)):
    if Alist.count(Aset[i]) == N: 
        ans += 1

print(ans)

Solution (Python):
from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = list(map(int, input().split()))
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in d.values():
    if value == n:
        cnt += 1
print(cnt)

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

for i in range(N):
  for j in range(1, len(A[i])):
    like[A[i][j]] += 1


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

print(count)

Solution (Python):
def main():
    N, M = map(int, input().split())
    S = set(range(1,M+1))
    for i in range(N):
        K, *A = map(int,input().split())
        S = S & set(A)
    print(len(S))  

main()

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 = S&set(a)
print(len(S))

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

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())
A=[list(map(int, input().split())) for _ in range(N)]

answer=[0]*M

for i in range(len(A)):
    for j in range(1, len(A[i])):
        answer[A[i][j]-1]+=1

count=0
for i in range(len(answer)): 
        if answer[i]/N==1:
            count+=1
print(count)

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

Solution (Python):
n,m = map(int,input().split())
vote = [0 for i in range(m)]
for i in range(n):
    l = [int(j) for j in input().split()]
    for j in range(l[0]):
        k = l[j+1]-1
        vote[k] = vote[k] + 1 
flag = 0
for i in range(m):
    if vote[i] == n:
        flag = flag + 1
print(flag)

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=s&set(a)
print(len(s))

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

Solution (Python):
N,M = map(int,input().split())
Data = [0]*M
for _ in range(N):
    fabList = list(map(int,input().split()))
    fabList.pop(0)
    for f in fabList:
        Data[f-1] += 1
ans = 0
for i in range(M):
    if Data[i] == N:
        ans += 1

print(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 = S & set(A)
print(len(S))

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

for i in range(1,len(kx[0])):
  for j in range(1,n):
    if kx[0][i] in kx[j][1:]:
      c1 += 1
  if c1 == n-1:
    c2 += 1
  c1 = 0

print(c2)

Solution (Python):
N, M = map(int, input().split())
Alst = []
cnt = 0
for _ in range(N):
    K, *A = map(int, input().split())
    Alst += A
for i in range(1, M + 1):
    if Alst.count(i) == N:
        cnt += 1
print(cnt)

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

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

Solution (Python):
n,m = map(int,input().split())
like = [0]*m
for i in range(n):
    *k, = map(int,input().split())
    k = k[1:]
    for j in k:
        like[j-1]+=1
ans=0
for i in like:
    if i==n:
        ans+=1
print(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())

L = [0] * (M + 1)

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

print(L.count(N))

Solution (Python):
N, M = map(int, input().split())
l = [0] * (M + 1)
for _ in range(N):
  a = list(map(int, input().split()))
  for i in range(1, a[0] + 1):
    l[a[i]] += 1

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

Solution (Python):
N, M = map(int, input().rstrip().split())
li = [[int(_) for _ in input().rstrip().split()] for _ in range(N)]
for i in range(N):
    del li[i][0]

ans = 0
for i in range(M):
    Flag = "OK"
    for j in range(N):
            if not i+1 in li[j]:
                Flag = "NG"
    if Flag == "OK":
        ans += 1

print(ans)

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

 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m = na()

food = [1] * (m + 1)

for i in range(n):
    a = na()
    for f in range(1, len(food)):
        if f not in a[1:]:
            food[f] = 0

print(sum(food[1:]))

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

print(len(s))

Solution (Python):
def test():
    n,m = map(int,input().split())
    d = list(map(int,input().split()))
    b = set(d[1:])
    for i in range(n-1):
        a = list(map(int,input().split()))
        c = set(a[1:])
        b = b & c

    print(len(b))


if __name__ == "__main__":
    test()

Solution (Python):
n,m = map(int,input().split())
like =[]
for i in range(n):
    ka = list(map(int,input().split()))
    ka.pop(0)
    for j in range(m):
        if (j+1 in ka) and i == 0:
            like += [j+1]
        elif j+1 not in ka and j+1 in like and i != 0:
            like.remove(j+1)
print(len(like))

Solution (Python):
import collections

def main():
    N, M = map(int, input().split())
    d = collections.defaultdict(int)
    for _ in range(N):
        kA = list(map(int, input().split()))
        for i in range(1, kA[0]+1):
            d[kA[i]] += 1

    count = 0
    for A in d:
        if d[A] == N: count += 1
    return count

if __name__ == '__main__':
    print(main())

Solution (Python):
import collections
n, m = map(int, input().split())
ls = [0] * m
for i in range(n):
    a = list(map(int, input().split()))
    for j, v in enumerate(a):
        if j != 0:
            ls[v-1] += 1
cnt = 0
for i in ls:
    cnt += 1 if i == n else 0
print(cnt)

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


if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split())
ans = {int(x+1) for x in range(m)}
for i in range(n):
    a = [int(x) for x in input().split()]
    b = {int(i) for i in a[1:]}
    ans = ans & b
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())
D=set()

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

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

food=[]

for i in range(n):
    food.append(list(map(int,input().split())))

for i in food:
    del i[0]


if n==1:
    print(len(food[0]))

else:

    ans=0
    for i in range(1,m+1):
        cnt=0
        for sfood in food:
            if i in sfood:
                cnt+=1

        if cnt==n:
            ans+=1
    print(ans)

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

count = [0 for i in range(M)]
for i in range(N):
  for j in range(M):
    count[j] += A[i].count(j+1)

print(sum([1 for i in count if i == N]))

Solution (Python):
N,M = map(int,input().split())
ans = set(range(1,M+1))
for i in range(N):
    k,*a, = map(int,input().split())
    ans = ans & set(a)

print(len(ans))

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

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

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

S = set(range(1, m + 1))
for a in A:
    S &= set(a)

print(len(S))

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())

ans = [0]*M

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

count = 0

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

print(count)

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):
N,M=map(int, input().split())
A=[0]*M
for _ in range(N):
    _,*T=map(int,input().split())
    for t in T:
        A[t-1]+=1
print(A.count(N))

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())
s = set(range(1, m+1))

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

Solution (Python):
n,m = list(map(int, input().split()))
d = {}
ll = []
food = [i for i in range(m)]
food2 = []
for i in range(n):
	l = list(map(int, input().split()))
	ll.append(l)
for i in range(n):
	for j in range(1,ll[i][0]+1):
		if not ll[i][j] in food2:
			food2.append(ll[i][j])
			d.setdefault(ll[i][j],0)
		d[ll[i][j]] += 1
print(len([i for i in d.values() if i == n]))

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

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

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):
n, m = map(int, input().split())
s = set([i for i in range(1, m+1)])

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

print(len(s))

Solution (Python):
n,m = map(int,input().split())
s = []
for i in range(n):
    s.append(list(map(int,input().split())))
cnt = 0
for j in range(1,m+1):
    check = True
    for i in range(n):
        if not j in s[i][1::]:
            check = False
    if check:
        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 = list(map(int, input().split()))
like = []
for _ in range(n):
  ka = list(map(int, input().split()))
  k = ka[0]
  a = ka[1:]
  for e in a:
    like.append(e)

ans = 0
for i in range(1, m + 1):
  if like.count(i) == n:
    ans += 1

print(ans)

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

Solution (Python):
n, m = map(int, input().split())
ans = set(map(str, range(1, m+1)))
for _ in range(n):
    ans = ans & set(input().split()[1:])
print(len(ans))

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

d={n:0 for n in range(1,m+1)}

count=0

for i in range(n):
    k=[int(x) for x in input().split()]
    for j in range(1,len(k)):
        d[k[j]]+=1

for buf in range(1,m+1):
    if d[buf]==n:
        count+=1

print(count)

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

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

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

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

Solution (Python):
import collections as col
n, m = map(int, input().split())
t = [list(map(int,input().split())) for _ in range(n)]
t2 = []

for i in range(n):
    t[i].remove(t[i][0])
    t2 += t[i]

ans = col.Counter(t2)
ans = ans.values()
ans = list(ans)

print(ans.count(n))

Solution (Python):
n, m = map(int, input().split(' '))
_, *intersection = map(int, input().split(' '))
intersection = set(intersection)
for _ in range(1, n):
    _, *newlist = map(int, input().split(' '))
    intersection = intersection & set(newlist)
print(len(intersection))

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

for j in range(n):
  L=list(map(int,input().split()))

  for i in range(1,L[0]+1):
    s[L[i]-1][j]=1

for i in range(m):
  if s[i]==[1]*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)
ans = 0
print(len(s))

Solution (Python):



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


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


print(ans.count(N))

Solution (Python):


n, m = map(int, input().split())
foods = [1] * m
for n_i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    a = ka[1:]
    mask = [0] * m
    for a_i in a:
        mask[a_i-1] = 1
    for m_i in range(m):
        foods[m_i] *= mask[m_i]

print(sum(foods))

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

arr=[]
for _ in range(n):
  k,*a=list(map(int,input().split()))
  arr.extend(a)

c = collections.Counter(arr)

cnt=0
for c_ in c.most_common():
  if n == c_[1]:
    cnt+=1
print(cnt)

Solution (Python):
from collections import defaultdict

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

dic = defaultdict(int)
for _ in range(n):
  k,*a=list(map(int,input().split()))
  for a_ in a:
    dic[a_]+=1

cnt=0
for v in dic.values():
  if v == n:
    cnt+=1
print(cnt)

Solution (Python):
n,m=map(int,input().split())
ans=0
dic={}
a=[]
for b in range(n):
  k,*a=map(int,input().split())
  for c in a:
    if c in dic:
      dic[c]+=1
    else:
      dic[c]=1
for d in dic:
  if dic[d]==n:
    ans+=1
print(ans)

Solution (Python):
def solve():
    n, m = map(int, input().split())
    ka = [list(map(int, input().split())) for _ in range(n)]
    common = set([i for i in range(1, m + 1)])
    for i in range(len(ka)):
        common = set(set(ka[i][1:]) & common)
    return len(common)


if __name__ == "__main__":
    print(solve())

Solution (Python):
n,m=map(int,input().split())
l=[]
ans=[]
for _ in range(n):
        k=list(map(int,input().split()))
        l.append(k[1:])
for i in range(1,m+1):
        for j in range(n):
                if i in l[j]:
                        continue
                else:
                        break
        else:
                ans.append(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())
fav = [0] * m
for _ in [0]*n:
    k, *A = map(int, input().split())
    for a in A:
        fav[a-1] += 1
print(len(list(filter(lambda x: x == n, fav))))

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

Solution (Python):
import math
import copy

inputa = input().split()



a = int(inputa[0])
b = int(inputa[1])









inputList=[]
for i in range(a):
    inputNum = input().split()
    inputNum = [int(x) for x in inputNum]
    inputList.append(inputNum)






ans = [True]*b

for i in range(len(inputList)):
    anstmp = [False]*b

    for j in range(1, len(inputList[i])):
        anstmp[inputList[i][j]-1] = True

    for j in range(b):
        ans[j] = ans[j] * anstmp[j]

cnt = 0
for i in range(b):
    if ans[i] == True:
        cnt += 1

print(cnt)

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