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):
icase=0
if icase==0:
    n,m=map(int,input().split())

    lista=list(map(int,input().split()))
    ki=lista[0]
    aset=set(lista[1:])
    for i in range(1,n):
        lista=list(map(int,input().split()))
        ki=lista[0]
        a=set(lista[1:])
        aset=aset & a
    print(len(aset))

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a-1] = 1
    count = 0
    for j in range(M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()

Solution (Python):
import collections
N,M=map(int,input().split())
a=[]
for _ 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())

li = [0] * 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):
n, m=map(int, input().split())
favl=[list(map(int, input().split())) for _ in range(n)]
favset=[set(favl[i][1:favl[i][0]+1]) for i in range(n)]
allfav=favset[0]
for i in range(1, n):
  allfav=allfav & favset[i]
print(len(allfav))

Solution (Python):

N, M = [int(s) for s in input().split()]
tmp = [[int(s) for s in input().split()] for _ in range(N)]
a = [tmp[i][1:] for i in range(N)]

kind = 0

for i in range(1, M + 1):
    everyone = True

    for j in range(N):
        if i not in a[j]:
            everyone = False
            break

    if everyone:
        kind += 1

print(kind)

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

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

ss = Counter(s)

ans = []
for k, v in ss.items():
  if v == n:
    ans.append(k)
    
print(len(ans))

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

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

    for j in A:
        a[j-1] -= 1


count = 0
for i in a:
    if i == 0:
        count += 1

print(count)

Solution (Python):


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

Solution (Python):
def main():
    N, M = map(int, input().split())
    cnts = [0 for _ in range(M)]
    for _ in range(N):
        A = list(map(int, input().split()))
        K = A.pop(0)
        for a in A:
            cnts[a-1] += 1
    
    ans = cnts.count(N)
    print(ans)


if __name__ == "__main__":
    main()

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

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

se = set(range(M+1))
for _ in range(N):
  enquete = [int(x) for x in input().split()]
  se &= set(enquete[1:])

answer = len(se)
print(answer)

Solution (Python):
n,m=list(map(int,input().split()))
a=set(input().split()[1:])
for i in range(n-1):
  b=set(input().split()[1:])
  a=set(a&b)
print(len(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):
from collections import deque,Counter
N,M = map(int,input().split())
A = []
for i in range(N):
  KA = deque(list(map(int,input().split())))
  KA.popleft()
  A += KA
A = Counter(A)
values, counts = zip(*A.most_common())

print(counts.count(N))

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

print(ans)

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

Solution (Python):
N, M = map(int, input().split())
A = [[int(x) for x in input().split()] for y in range(N)]
ans = set(int(z) for z in range(1, 31))
for i in range(N):
    A[i].pop(0)
    ans = ans & set(A[i])
print(len(ans))

Solution (Python):
N, M = map(int, input().split())
l = list()
for i in range(N):
    la = [int(x) for x in input().split()]
    for j in range(1, la[0] + 1):
        l.append(la[j])

ans = 0

for k in range(M + 1):
    if l.count(k) == N:
        ans += 1
print(ans)

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

Solution (Python):
def myAnswer(N:int,M:int,K:list,A:list) -> int:
   kinds = [0 for i in range(M)]
   total = 0
   for a in A:
      for k in a:
         kinds[k-1]+=1
   for kind in kinds:
      if(kind == N):
         total+=1
   return total



def modelAnswer():
   tmp=1
def main():
   N,M = map(int,input().split())
   K =[]
   A = []
   for _ in range(N):
      tmp = list(map(int,input().split()))
      K.append(tmp.pop(0))
      A.append(tmp)
   print(myAnswer(N,M,K,A))

if __name__ == '__main__':
   main()

Solution (Python):
from collections import Counter
N, M = map(int,input().split())
cnt = [0 for _ in range(M+1)]
for _ in range(N):
    Q = list(map(int,input().split()))
    for i in Q[1:]:
        cnt[i] += 1
d = Counter(cnt)
print(d[N])

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

print(ary.count(N))

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

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

print(ans.count(n))

Solution (Python):
N, M = map(int, input().split())
surveys = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(1, M+1):
    flag = True
    for survey in surveys:
        if i not in survey[1:]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

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

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

Solution (Python):
def i(): return list(map(int, input().split()))
l = [set(i()[1:]) for _ in range(i()[0])]
print(len(l[0].intersection(*l[1:])))

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,food[0]+1):
    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())

likes = set(range(1, M + 1))
for _ in range(N):
    A = list(map(int, input().split()[1:]))
    likes = likes.intersection(set(A))

print(len(likes))

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

foods = []
for i in range(m): foods.append(True)

for i in range(n):
    k = list(map(int, input().split()))
    k.pop(0)
    for j in range(1,m+1):
        if j not in k: foods[j-1] = False

print(foods.count(True))

Solution (Python):
n, m = map(int, input().split())
a = list()
favorite = {i+1: 0 for i in range(m)}
for i in range(n):
    x = list(map(int, input().split()))
    a.append(x)

for i in a:
    for j in i[1:]:
        favorite[j] += 1

ans = 0

for i in favorite.values():
    if i == n:
        ans += 1

print(ans)

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

print(like.count(N))

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

k0 = list(map(int, input().split()))
k0.pop(0)
le = len(k0)
aut = []

for i in range(n-1):
    ka = list(map(int, input().split()))
    ka.pop(0)
    for j in range(le):
        num = k0[j]
        if num not in ka:
            aut.append(num)

print(le-len(set(aut)))

Solution (Python):
n, m = map(int, input().split())
dict = {i:True for i in range(1, m+1)}
ans = 0

for i in range(n):
    _, *a = map(int, input().split())
    for j in range(1, m + 1):
        if j not in a:
            dict[j] = False

for i in range(1, m + 1):
    if dict[i]:
        ans += 1

print(ans)

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

Solution (Python):













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

times = n
table = []
for _ in range(times):
    table.append(list(map(int,input().split()))) 

for lis in table:
    ansset = ansset & set(lis[1:])

print(len(ansset))

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

H=[0]*N
for i in range(N):
    K,*H[i],=map(int,input().split())

ans=M
j=1
while j<=M:
    for x in H:
        if j not in x:
            ans-=1
            break
    j+=1

print(ans)

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

i = 0
while i < n:
    k_list = list(map(int, input().split(' ')))
    lcopy = List[:]
    for l in lcopy:
        if l not in k_list[1:]:
            List.remove(l)
            
    i += 1
print(len(List))

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

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

Solution (Python):
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
y=0
if n!=1:
    for i in range(m):
        x=0
        for j in range(n):
            if i+1 in a[j][1:a[j][0]+1]:
                x+=1
            else:
                x+=0
        if x==n:
            y+=1
    print(y)
else:
    for i in range(2,a[0][0]+1):
        if a[0][1]!=a[0][i]:
            y+=1
    print(y+1)

Solution (Python):
n,m=map(int,input().split())
M=[0]*31
for i in range(n):
    a=[int(_) for _ in input().split()]
    for j in range(a[0]):
        M[a[j+1]]+=1

print(M.count(n))

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

favorite=set(list(range(1,m+1)))

for i in range(n):
    m=[int(i) for i in input().split()]
    m=m[1:]
    m=set(m)
    favorite=favorite&m
print(len(favorite))

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 cnt:
  ans += (i == n)
print(ans)

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

Solution (Python):
n, m = map(int, raw_input().split())
like = [0] * m
for _ in xrange(n):
    for a in map(int, raw_input().split())[1:]:
        like[a - 1] += 1
print sum(c == n for c in like)

Solution (Python):
p,q= input().split()
a,b =(int(p), int(q))
ans_list = []
for i in range(a):
    a_list = input().split()
    ans_list.append(a_list)
ans = 0
for i in range(b+1):
    count = 0
    for j in range(a):
        if str(i)in ans_list[j][1:]:
            count +=1
    if count == a:
        ans +=1
        
print(ans)

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

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

ans = []

flg = 0
for i in range(N):
    if flg == 0:
        K = list(map(int, input().split()))
        K = K[1:]
        ans += K
        flg = 1
    else:
        K = list(map(int, input().split()))
        K = K[1:]
        
        ans = set(ans)&set(K)

print(len(ans))

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n, m = MII()
    food = set(MII()[1:])
    for i in range(n-1):
        a = MII()[1:]
        food &= set(a)
    print(len(food))

if __name__ == '__main__':
    main()

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
l = set(range(1,m+1))

for i in range(n):
    A = set(iil()[1:])
    l = l&A

print(len(l))

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

temp_l = [0]*M

for i in range(N):
    for j in range(1, l[i][0]+1):
        temp_l[l[i][j]-1] += 1

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

print(ans)

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

Solution (Python):
N,M = list(map(int,input().split()))
a = list(map(int,input().split()))
a.pop(0)
ans = a
for i in range(N-1):
    a = list(map(int,input().split()))
    a.pop(0)
    x = set(a) & set(ans)
    ans = list(x)
print(len(ans))

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

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

counter = 0

for i in range(1, 31):
  for j in range(n):
    judge = False
    for k in range(1, len(List[j])):
      if List[j][k] == i:
        judge = True
    if not judge:
      break
  if judge:
  	counter += 1
      

print(counter)

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

for i in range(n):
    x = list(map(int,input().split()))
    x.pop(0)
    for j in range(1,m+1):
        if j not in x:
            ans[j-1] = 0

print(ans.count(1))

Solution (Python):
n,m=map(int,input().split())
l=[int(i) for i in input().split()]
l=l[1:]
for i in range(n-1):
  s=[int(j) for j in input().split()]
  s=s[1:]
  ln=[]
  for le in l:
    if le in s:
      ln.append(le)
  l=ln
print(len(l))

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

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

Solution (Python):

N, M = map(int, input().split())
memo = [0]*(M+1)

for _ in range(N):
    Ki, *A = map(int, input().split())
    for item in A:
        memo[int(item)] += 1

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

print(ans)

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

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

n, m = map(int, input().split()) 
d = []
for _ in range(n):
    food = set(input().split()[1:])
    d.append(food)

s = d[0]
for i in range(n):
    s = s & d[i]
print(len(s))

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
cnt = [0]*m
for i in range(n):
    query = LI()
    for j in query[1:]:
        cnt[j-1] += 1
ans = 0
for i in cnt:
    if i == n:
        ans += 1
print(ans)

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n,m = map(int,input().split())
  OK = [0] * m + [0]
  cnt = 0
  while True:
    try:
      LIST = list(map(int,input().split()))
      k = LIST[0]
      A = LIST[1:]
      for i in range(k):
        OK[A[i]] += 1
    except:
      break
  
  for i in range(m + 1):
    if OK[i] == n:
      cnt += 1
    else:
      pass
  print(cnt)
  
  
  
  
if __name__ == '__main__':
  main()

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

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

Solution (Python):
import collections
n, m = map(int, input().split())
a_list = sum([list(map(int, input().split()))[1:] for _ in range(n)], [])
col = collections.Counter(a_list)
print(len([k for k, v in col.items() if v == n]))

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


K = []
A = []
for _ in range(N):
    tmp = list(map(int,input().split()))
    K.append(tmp[0])
    A += tmp[1:]
    

cnt = 0
for i in range(1,M+1):
    
    if(A.count(i) == N):
        cnt += 1
print(cnt)

Solution (Python):
def main():
  
  
  
  n,m = list(map(int,input().split()))
  
  
  
  a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = [0]*m
  
  for i in range(n):
    for k in range(1,a[i][0]+1):
      lis[a[i][k]-1] += 1
  print(lis.count(n))  
if __name__ == '__main__':
  main()

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

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

print(m.count(n))

Solution (Python):

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

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

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

for i in cnt:
    if i == n:
        ans += 1

print(ans)

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

a = list(map(int, input().split()))
del a[0]
a = set(a)
ref = a

for i in range (n - 1):
    a = list(map(int, input().split()))
    del a[0]
    a = set(a)
    ref = ref & a

print(len(ref))

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

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

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

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

KA=[set(val[1:]) for val in KA]

for val in KA:
    KA[0]=KA[0].intersection(val)

print(len(KA[0]))

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

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

import numpy as np

food_list = np.zeros(m)

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

print(ans)

Solution (Python):
N, M = map(int, input().split())
m = [i + 1 for i in range(M)]
for j in range(N):
  K = list(map(int, input().split()))
  n = K[0] + 1
  m = [K[k] for k in range(n) if k != 0 and (K[k] in m)]
print(len(m))

Solution (Python):
N, M = map(int,input().split())
nlike = [0]*M
for n in range(N):
  tmp = list(map(int,input().split()))
  for k in range(1,tmp[0]+1):nlike[tmp[k]-1] +=1
cnt = 0
for m in range(M):
  if nlike[m] == N:cnt += 1
print(cnt)

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

loves = {}
for i in range(N):
    for j in range(1, A[i][0]+1):
        love = A[i][j]
        if love in loves:
            loves[love] += 1
        else:
            loves[love] = 1

print( len(list(filter( lambda x: loves[x] == N, loves ))))

Solution (Python):
N, M = map(int, input().split())
cnt = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        cnt[a - 1] += 1
print(sum(c == N for c in cnt))

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

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

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

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



like_food = {}
for i in range(N):
    for j in range(len(lists[i])):
        j = lists[i][j]
        if j not in like_food.keys():
            like_food[j] = 1
        elif j in like_food.keys():
            like_food[j] += 1


count = 0
for i in like_food.values():
    if i == N:
        count += 1
    else:
        continue

print(count)

Solution (Python):
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    counter = Counter()
    for _ in range(N):
        K, *A = map(int, input().split())
        counter += Counter(A)
    print(sum(1 for c in counter.values() if c == N))

main()

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

surveys = []

for i in range(N):
    z = [int(i) for i in input().split()]
    surveys.append(z[1:])

joint_surveys = []

for i in surveys:
    joint_surveys = joint_surveys + i

res = []

for i in range(1, M+1):
    if joint_surveys.count(i) == N:
        res.append('x')

print(len(res))

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

K = []
A = []
ans = 0

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

for i in range(1, M+1):
    c = 0
    for a in A:
        if i in a:
            c += 1

    if c == N:
        ans += 1

print(ans)

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

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

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.pop(0)
    ans &= set(A)
print(len(ans))

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

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(int)
for i in range(N):
  A = list(map(int, input().split()))
  for i in range(1, A[0]+1):
    d[A[i]] += 1
ans = 0
for v in d.values():
  if v == N:
    ans += 1
print(ans)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    alist=[]
    for i in range(n):
        ka=LIST()
        ka.pop(0)
        ka=set(ka)
        alist.append(ka)
    for i in range(n-1):
        alist[n-1]=alist[n-1]&alist[i]
    print(len(alist[n-1]))
if __name__ == '__main__':
    do()

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

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

Solution (Python):
import sys
input = sys.stdin.readline
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from itertools import permutations

def main():
    n,m = map(int,input().split())
    food = [0] * m
    for i in range(n):
        a = list(map(int,input().split()))
        for i in range(1,len(a)):
            food[a[i] - 1] += 1
    
    cnt = 0
    for i in range(m):
        if food[i] == n:
            cnt += 1
    
    print(cnt)


if __name__=='__main__':
    main()

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

Solution (Python):
N,M = map(int,input().split())
K=[0]*N
A=[[0] for _ in range(N)]
for i in range(N):
  tmp = list(map(int,input().split()))
  K[i]=tmp[0]
  A[i]=set(tmp[1:])
  
for j,item in enumerate(A):
  if j==0:
    ans=A[j]
    
  else:
    ans=ans.intersection(item)
    
    
print(len(ans))

Solution (Python):
N,M=map(int,input().split())
l=[0]*M
for _ in range(N):
    K,*A=map(int,input().split())
    for i in range(K):
        l[A[i]-1]+=1
print(l.count(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 = {i:0 for i in range(1,m+1)}
for i in range(n):
    k,*a = map(int, input().split())
    for j in a:
        like[j]+=1
ans = 0
for i in range(1,m+1):
    if like[i]==n:ans+=1
print(ans)

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

Solution (Python):
from collections import Counter

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

d = Counter(a)
ans = [k for k, v in d.items() if v == n]
print(len(ans))

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

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

for c in list_score:
    ans = ans & set(c[1:])

print(len(ans))

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

like = [0]*M
for i in range(N):
    for j in range(1,len(K[i])):
        like[K[i][j]-1] += 1

c = 0
for i in range(M):
    like[i] -= N


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

print(c)

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

Solution (Python):
import numpy as np
n,m = list(map(int,input().split()))
t = np.zeros(m,dtype=int)
count = 0
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,a[0]+1):
        t[a[j]-1]+=1
for i in range(m):
    if t[i] == n:
        count+=1
print(count)

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

Solution (Python):
n,m = map(int, input().split( ))
bit = (1<<m)-1
for i in range(n):
    _, *a, = map(int, input().split( ))
    tmp = 0
    for aj in a:
        tmp |= 1<<(aj-1)
    bit &= tmp



ans = 0
for i in range(m):
   if (bit>>i)&1:
       ans += 1
print(ans)

Solution (Python):
N, M = map(int, input().split())
like = [0] * (M + 1)
for _ in range(N):
    KA = list(map(int, input().split()))
    for i in range(1, len(KA)):
        like[KA[i]] += 1
like.sort(reverse=True)
ans = 0
for i in range(M + 1):
    if like[i] == N:
        ans += 1
    else:
        break
print(ans)

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 range(1,len(a)):
        cnt[a[j]-1] +=1
print(cnt.count(n))