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())
K = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(1, M+1):
    for j in range(N):
        if i not in K[j][1:]:
            break
    else:
        cnt += 1
print(cnt)

Solution (Python):
N = list(map(int,input().split()))
ans = set([])
for i in range(N[1]+1):
	ans.add(i)
for i in range(N[0]):
	receive = list(map(int,input().split()))
	sub_ans = set(receive[1:])
	ans = ans & sub_ans
print(len(ans))

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

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

print(ans)

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

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

print(ans)

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


if __name__ == '__main__':
    solve()

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

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


ans = 0
for x in range(1,m+1):

    if n == l.count(x):
        ans += 1

print(ans)

Solution (Python):
import collections

n, m = [int(i) for i in input().split()]
ka = []
counter = 0

for i in range(n):
    l = list(int(i) for i in input().split())
    for j in l[1:]:
        ka.append(j)
        
c = collections.Counter(ka).most_common()

for i in c:
    if i[1] == n:
        counter += 1
print(counter)

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

for i in range(n):
    a = [int(i) for i in input().split()]
    s = s & set(a[1: a[0] + 1])

print(len(s))

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

shugou = set(li[0])
for i in range(n):
    shugou = shugou & set(li[i])

print(len(shugou))

Solution (Python):
import math


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

Solution (Python):
n,m=map(int,input().split())
k=[]
a=[]
for i in range(n):
  b=list(map(int,input().split()))
  k.append(b[0])
  a.append(b[1:])
d={}
for i in range(n):
  for j in range(k[i]):
    if a[i][j] not in d:
      d[a[i][j]]=1
    else:
      d[a[i][j]]+=1
nd=list(d.values())
cnt=0
for i in range(len(nd)):
  if nd[i]==n:
    cnt+=1
print(cnt)

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

suki = []
for i in range(N):
  K[i].pop(0)
  K[i] = sorted(K[i])
  for j in range(1,M+1):
    if all(K[i].count(c) == 1 for c in [j]):
      continue
    else:
      suki.append(j)
print(M-len(set(suki)))

Solution (Python):
N,M = map(int,input().split())
An = []
for i in range(N):
  A = list(map(int,input().split()))
  An.extend(A[1:])
Ans = 0
for i in range(M):
  if An.count(i+1)==N:
    Ans += 1
print(Ans)

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

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

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

cnt = 0
for t in table:
    if t == n:
        cnt += 1

print(cnt)

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

ans = set(range(1, m+1))
for i in ka:
    ans &= set(i[1:])
print(len(ans))

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

ans = set(range(1, m+1))
for i in ka:
    ans &= set(i[1:])
print(len(ans))

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

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

for k in range(m):
  num += ans[k]//n
  
print(num)

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

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

l = set(List[0][1:])
for i in range(n):
    l = l & set(List[i][1:])
print(len(l))

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

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

Solution (Python):

import sys
import itertools
import math

N, M=input().split()
N=int(N)
M=int(M)
i=0
katu_list=[]
katu_sublist=[]

for i in range(M):
 katu_list.append(i+1)


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


















i=0
j=0
k=0
l=0
for i in range(N):
 
 
 
 for j in range(food_list[i][0]):
  for k in range(M):
   if food_list[i][j+1]==katu_list[k]:
     katu_sublist.append(katu_list[k])
     
   else:
       pass

 katu_list=[]
 for l in range(len(katu_sublist)):
   katu_list.append(katu_sublist[l])
 M=len(katu_list)
 katu_sublist=[]
print(len(katu_list))

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

ans = 0
count = 1
for j in range(1, len(List[0])):
    for i in range(1, n):
        if List[0][j] in List[i][1:]:
            count += 1
            if count == n:
                ans += 1
    count = 1
if n == 1:
    print(List[0][0])
else:
    print(ans)

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

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

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

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


print(len(ret))

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

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

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

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

for r in a:
  for c in r:
    ans[c-1]+=1
    
print(sum([x==n for x in ans]))

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N, M = [int(x) for x in readline().rstrip().split()]
A = []
B = [0] * M
for _ in range(N):
    temp = [int(x) for x in readline().rstrip().split()]
    A.append(temp[1:])
for i in A:
    for j in i:
        B[j-1] += 1
B = np.array(B)
cnt = np.count_nonzero(B == N)
print(cnt)

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

Solution (Python):
import collections
n,m = map(int,input().split())
h = []
for i in range(n):
  h[len(h):len(h)] = list(map(int,input().split()))[1:]
ans = 0
count = collections.Counter(h)
for v in count.values():
  if v == n:
    ans += 1
print(ans)

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


dic={}
for i in range(1,m+1):
  dic[i]=0
ans=0
for i in range(n):
  k=l[i][0]
  templ=l[i][1:k+1]
  for a in templ:
    dic[a]=dic[a]+1
for v in dic.values():
  if v==n:
    ans+=1
print(ans)

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())
lst = []
for i in range(n):
  tmplst = [int(i) for i in input().split()]
  tmp = 0
  for item in tmplst[1:]:
    tmp |= 1 << item
  lst.append(tmp)
ret = lst[0]
for item in lst[1:]:
  ret &= item
if ret:
  s = sum(map(int, bin(ret)[2:]))
  print(s)
else:
  print(0)

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

all_set = set()
for i in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    if i == 0:
        all_set = set(A)
    else:
        all_set = all_set & set(A)

print(len(all_set))

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

a = []
for i in range(n):
    k = [int(j) for j in input().split()]
    a.append(k[1:])

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

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
if max(l)==n:
    print(l.count(max(l)))
else:
    print(0)

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

ans = set(K[0][1:])
for li in K:
    ans = ans & set(li[1:])
print(len(list(ans)))

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

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

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

Solution (Python):
n,m=map(int,input().split())
L=[list(map(int,input().split())) for _ in range(n)]
food=L[0][1:]
good=[]
for i in range(1,n):
    for j in range(len(food)):
        if food[j] in L[i][1:]:
            good.append(food[j]) 
    food = good
    good=[]
print(len(food))

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

t = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        t[a - 1] += 1
print(t.count(N))

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

ls_k = [0] * n
ls_a = [0] * n
st_ans = {_ for _ in range(1, m+1)} 

for i in range(n):
    ls_k[i] = ls_ka[i][0]
    ls_a[i] = ls_ka[i][1:]
    st_ans &= set(ls_a[i])

print(len(st_ans))

Solution (Python):
N,M = map(int,input().split())
array2 = [0 for i in range(M+1)]
for i in range(N):
  array = list(map(int,input().split()))
  array.pop(0)
  for j in array:
    array2[j] += 1
c = 0
for k in array2:
  if k == N:
    c += 1
print(c)

Solution (Python):
N,M=map(int, input().split())
k,*a=map(int, input().split())
s=set(a)

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

Solution (Python):
import itertools

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

t = list(itertools.chain.from_iterable(t))
for i in set(t):
    if t.count(i) == N:
        ans += 1
print(ans)

Solution (Python):
A,B = map(int,input().split())
count = 0
for _ in range(A):
  N = list(map(int, input().split()))
  N.pop(0)
  if count == 0:
    K1 = set(N)
    count += 1
  else:
    K2 = set(N)
    K1 = K1 & K2
print(len(K1))

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

jandjplu1=set(KA[0])
for j in range(1,N):
    jandjplu1=jandjplu1 & set(KA[j-1]) & set(KA[j])

print(len(jandjplu1))

Solution (Python):
from functools import reduce

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

list_ccc =[]

for i in range(N):
    list_bbb =[]
    for j in range(1,list_aaa[i][0]+1):
        list_bbb.append(list_aaa[i][j])
    list_ccc.append(set(list_bbb))

print(len(reduce(lambda a,b: a.intersection(b),list_ccc)))

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

Solution (Python):
import os, sys, re, math

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

dic = {}

for _ in range(N):
    tmp = list(map(int,input().split(' ')))
    for i in range(1,len(tmp)):
        if tmp[i] in dic:
            dic[tmp[i]] += 1
        else:
            dic[tmp[i]] = 1

ret = 0
for v in dic.values():
    if v == N:
        ret += 1
print(ret)

Solution (Python):

import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

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


for i in range(n):
	del a[i][0]


b = sum(a,[])

c = list(set(b))


ans = 0
check = 0

for i in range(len(c)):
	check = b.count(c[i])
	if check == n:
		ans = ans + 1

print(ans)

Solution (Python):
import os, sys, re, math

(N, M) = [int(n) for n in input().split()]
favorites = [n + 1 for n in range(M)]
for i in range(N):
    d = [int(n) for n in input().split()]
    favorites = list(filter(lambda x: x in d[1:], favorites))

print (len(favorites))

Solution (Python):
N, M = map(int, input().split())
As = []
ans = [0] * 31
for n in range(N):
    ka = list(map(int, input().split()))
    
    for a in ka[1:]:
        ans[a] += 1

print(ans.count(N))

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

Solution (Python):
from collections import defaultdict

nPeople, nKinds = map(int, input().split())
d = defaultdict(int)
for _ in range(nPeople):
    for kind in list(map(int, input().split()))[1:]:
        d[kind] += 1
print(sum([d[kind] == nPeople for kind in d.keys()]))

Solution (Python):
n, m = list(map(int, input().split(' ')))
d = {}
for i in range(n):
  l = list(map(int, input().split(' ')))
  for j in l[1:]:
    d[j] = d.get(j, 0) + 1
ans = 0
for key in d:
  if d[key] == n:
    ans += 1
print(ans)

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

Solution (Python):
from collections import Counter
from itertools import chain

N, M = map(int, input().split())
AK = [list(map(int,input().split())) for i in range(N)]
A = [ak[1:] for ak in AK]
A = list(chain.from_iterable(A))

print(list(Counter(A).values()).count(N))

Solution (Python):
n,m=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    k[i].pop(0)
res = 0
for i in range(1,m+1):
    flag = 1
    for j in range(n):
        if not i in k[j]:
            flag = 0
            break
    res += flag

print(res)

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

Solution (Python):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
dic={}
a=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    for j in range(1,a[i][0]+1):
        if a[i][j] in dic:
            dic[a[i][j]]+=1
        else:
            dic[a[i][j]]=1

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

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

Solution (Python):
from collections import defaultdict

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

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



a = [k for k in dd.values() if k == n]

print(len(a))

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

Solution (Python):
from collections import Counter
ctr = Counter()
N, M = map(int,input().split())
for _ in range(N):
  ctr.update(list(map(int,input().split()))[1:])
print(len([None for v in ctr.values() if v == N]))

Solution (Python):

n, m = [int(s) for s in input().split()]

k = []
a = []

for _ in range(n):
    tmp = [int(s) for s in input().split()]
    k.append(tmp[0])
    a.append(tmp[1:])

foods = [0] * m

for i in range(n):
    for j in range(m):
        if j + 1 in a[i]:
            foods[j] += 1

print(foods.count(n))

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

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

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

  ans = 0
  for x in range(len(a[0])):
    for y in range(N - 1):
      if a[0][x] in a[y + 1]:
        if y + 1 == N - 1:
          ans += 1
      else:
        break
  print(ans)
else:
  print(A[0][0])

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

    array = []
    for i in range(n):
        if i == 0:
            array = set(list(map(int,input().split()))[1:])
        else:
            A = list(map(int,input().split()))
            k = A[0]
            A = set(A[1:])
            array = array & A
    print(len(array))


if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().split())
L = [0]*N
for i in range(N):
    L[i] = list(map(int,input().split()))
for i in range(N):
    del L[i][0]
L.sort() 

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

Solution (Python):
n,m=map(int,input().split(" "))
s=[input().split() for i in range(n)]
d=[]
for j in s:
    j=j[1:]
    for k in j:
        d.append(k)
f=[]
for h in d:
    if d.count(h)==n:
        f.append(h)
print(len(set(f)))

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

Solution (Python):
n,m=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))

Solution (Python):
n,m=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))

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

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

aL = []
for _ in range(n):
    kal = list(map(int,input().split()))
    al = kal[1:]
    aL.append(al)


tmp = aL[0]
for al in aL:
    tmp = set(al) & set(tmp)
    
print(len(tmp))

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

Solution (Python):

import sys










def main():
    nm, *lines = sys.stdin.readlines()
    n, m = [int(x) for x in nm.split()]
    likes = [[int(x) for x in line.split()] for line in lines]
    menu = set(range(1, m+1))
    res = menu
    for i in range(n):
        res &= set(likes[i][1:])
    
    print(len(res))

if __name__ == "__main__":
    main()

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

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

for i in range(n):
  k,*a=map(int,input().split())
  tmp+=list(a)
ans=sum(tmp.count(i)==n for i in range(1,m+1))
print(ans)

Solution (Python):


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

Solution (Python):
N,M = map(int,input().split())
dic = {}
for i in range(N):
    a = list(map(int,input().split()))
    a = a[1:]
    for j in a:
        if(j in dic):
            dic[j] += 1
        else:
            dic[j] = 1
ans = 0
for key,value in dic.items():
    if(value == N):
        ans += 1
print(ans)

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

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

K = [list(map(int, input().split())) for row in range(N)]
if N == 1:
	print(K[0][0])
else:
	for i in range(N):
		K[i].remove(K[i][0])

	foods = set(K[0])
	i = 0
	while i < N:
		foods = foods.intersection(set(K[i]))
		if foods == {}:
			
			break
			exit()
		i += 1
	print(len(list(foods)))

Solution (Python):
import numpy as np
N, M = map(int, input().split())
tmp = np.array([1]*M)
for n in range(N):
  K_A = list(map(int,input().split()))
  
  A = K_A[1:]
  tmp_n = np.array([0]*M)
  for a in A:
    tmp_n[a-1] = 1
  tmp = tmp*tmp_n
print(sum(tmp))

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

ans = 0
for num in likes:
    if num >=n:
        ans += 1
print(ans)

Solution (Python):
N,M=map(int,input().split())
A=[]
for i in range(N):
    a=list(map(int,input().split()))
    A.extend(a[1:])
    
U=0
for i in range(len(A)):
    if A.count(i)==N:
        U+=1
if N>1:
    print(U)
else:
    print(len(A))

Solution (Python):

import numpy as np

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

count = np.zeros(M, dtype=int)
for i in range(N):
  for ind in A[i]:
    count[ind-1] += 1

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

print(sum)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n,m=map(int,input().split())
    s = {i for i in range(1,m+1)}
    for _ in range(n):
        k,*aa=map(int,input().split())
        s&=set(aa)
    print(len(s))

main()

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

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

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

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

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

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

for val in range(n):
    tmp = list(map(int,input().split()))
    k = tmp[0]
    if val == 0:
        a_L = set(tmp[1:])
    else:
        a_L = set(tmp[1:]) & a_L

print(len(a_L))

Solution (Python):
n, m = map(int,input().split())
l = [0 for i in range(m)]
for i in range(n):
  s = list(map(int, input().split()))
  for j in range(1, s[0]+1):
    l[s[j]-1] += 1
l = list(map(lambda x: x//n, l))
print(sum(l))

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

Solution (Python):
n, m =map(int, input().split())
for i in range(n):
	a = list(map(int, input().split()))
	a.pop(0)
	if i == 0:
		b = set(a)
	b = set(a) & b
print (len(b))

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

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

for i in range(N - 1):
    k, *a = map(int, input().split())
    s = set(a)
    sa = s & sa

print(len(sa))

Solution (Python):
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

lin = []
for i in range(n):
    lin.append(li[i][1:])

flat = [flatten for inner in lin for flatten in inner]

flat.sort()
point = 0
for i in range(1,m+1):
    if flat.count(i) == n:
        point += 1
print(point)

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

for i in range(N):
  x[i].pop(0)

t = set(x[0])
for i in range(1,N):
  t &=set(x[i])
print(len(list(t)))

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

Solution (Python):
N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
K = []
for i in range(N):
    K.append(A[i].pop(0))
ans = A[0]
for j in range(1,N):
    ans = set(ans)&set(A[j])
print(len(ans))

Solution (Python):
N,M = [int(x) for x in input().split()]
FOODS=set(range(1,M+1))

for i in range(N):
    A=[int(x) for x in input().split()]
    FOODS = FOODS & set(A[1:])
ans=len(FOODS)
print(ans)

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

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

Solution (Python):
n,m=map(int,input().split())
f=[]
for i in range(n):
    y=input().split()
    for g in range(len(y)):
        y[g]=int(y[g])
    f.append(y)
    f[i].remove(f[i][0])
for j in range(n):
    f[j]=set(f[j])
for k in range(n):
    if k==0:
        x=f[k]
    else:
        x=x&f[k]
print(len(x))

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




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

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

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

k_list = []
for i in range(N):
    num = in_list[i][0]
    k_list = k_list + in_list[i][1: num + 1]

count = 0
for i in range(1, M + 1):
    if k_list.count(i) == N:
        count += 1
    else:
        pass

print(count)

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

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

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

print(ans)

Solution (Python):
import itertools

N, M = map(int, input().split())
K_A = []
A = []
X = []
ans = 0

for _ in range(N):
    K_A.append(list(map(str, input().split())))

for _ in range(N):
    A.append(K_A[_][1:])

A = list(itertools.chain.from_iterable(A))

for m in range(1, M+1):
    count = A.count(str(m))
    if count == 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())

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

total = 0

for i in range(1,len(A[0])):
	con = 1
	for j in range(1,N):
		a = A[0][i]

		if a in A[j][1:]:
			con *= 1
		else:
			con *= 0
	total += con
	
if N != 1:
	print(total)
else:print(A[0][0])

Solution (Python):
N, M = [int(x) for x in input().split()]
A = [[int(x) for x in input().split()[1:]] for _ in range(N)]
ans = 0
for i in range(1, M+1):
    all = 1
    for a in A:
        all *= (i in a)
    ans += all
print(ans)