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

D = {}
for i in range(N):
    K, *A = map(int, input().split())
    for a in A:
        if a not in D:
            D[a] = 0
        D[a] += 1
        
ans = 0
for v in D.values():
    if v == N:
        ans += 1
        
print(ans)

Solution (Python):
import itertools
import math

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

dic = {}
for i in range(len(a)):
    for j in range(len(a[i])):
        if a[i][j] not in dic:
            dic[a[i][j]] = 1
        else:
            dic[a[i][j]] += 1

count = 0
for i in range(len(dic.keys())):
    if list(dic.values())[i] == n:
        count += 1

print(count)

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



m_list = [n] * m


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

count0 = m_list.count(0)
print(count0)

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

for k in K:
    for like in k[1:]:
        likes[int(like)-1] += 1

print(likes.count(N))

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

Solution (Python):
N,M=map(int,input().split())
A=[0 for z in range(M)]
for i in range(N):
    K=[int(s) for s in input().split()]
    for t in range(1,len(K)):
        A[K[t]-1]+=1
ans=A.count(N)
print(ans)

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

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

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

print(ans)

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

for i in set(A):
    if A.count(i) == N:
        ans += 1
print(ans)

Solution (Python):
import itertools
N,M=map(int, input().split())
res=[]
for _ in range(N):
  data=list(map(int, input().split()))
  K=data.pop(0)
  A=data
  res.append(A)
flatten_list = list(itertools.chain.from_iterable(res))
cnt=0
for i in range(1, M+1):
  if flatten_list.count(i) == N:
    cnt +=1
print(cnt)

Solution (Python):
from collections import Counter

B=[]
n,m=map(int,input().split())
for _ in range(n):
	A=list(map(int,input().split()))
	B+=A[1:]													

C=list(Counter(B).values())					

print(C.count(n))

Solution (Python):

import sys
input = sys.stdin.readline









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

from collections import defaultdict
dic = defaultdict(int)
for A in AA:
    for a in A:
        dic[a] += 1

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

print(ans)

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

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

ans = 0
for i in range(m):
    flag = True
    for j in range(n):
        if i+1 not in k[j]:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

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

Solution (Python):
n,m = map(int,input().split())
k = [0]*n
a = [[0]]*n
for i in range(n):
  temp = list(map(int,input().split()))
  k[i] = temp[0]
  a[i] = temp[1:].copy()
lfood = set(range(1,m+1))
for i in range(n):
  tpset = set(a[i])
  lfood = lfood.intersection(tpset)
print(len(lfood))

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

for j in li:
    like = set(j[1:])
    food_list = food_list & like

print(len(food_list))

Solution (Python):
from collections import defaultdict

n,m = map(int, input().split())
dic = defaultdict(lambda:0)
for _ in range(n):
  ar = list(map(int, input().split()))
  for i in range(1,len(ar)):
    dic[ar[i]] += 1

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

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

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

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

print(len(ans))

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

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

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

ans=0  
for result in results:
    if result==n:
        ans+=1

print(ans)

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

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

ans=0  
for result in results:
    if result==n:
        ans+=1

print(ans)

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

l = [0 for _ in range(m)]

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

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

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

count_set = set(range(1, m + 1))
for _ in range(n):
    temp_list = [int(x) for x in input().split()]
    temp_list[0] = 0
    count_set &= set(temp_list)
print(len(count_set))

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

def resolve():
    n,m=map(int, input().split())
    checkl=[0]*m
    for i in range(n):
        a=list(map(int,input().split()))
        b=a[1:]
        for i in range(len(b)):
            checkl[b[i]-1]+=1
    print(checkl.count(n))

resolve()

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

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

print(F.count(N))

Solution (Python):
from collections import Counter as counter

ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))

def main(n,m,k):
    res = []
    a = []
    for i in k:
        a.extend(i[1:])
    c = counter(a)
    for i in range(1,m+1):
        if c[i] == n : res.append(i)
    return len(res)
    
n,m = mi()
k = mix(n)
print(main(n,m,k))

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

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

favorite = [0 for i in range(M)]
child = [input().split() for i in range(N)]

for i in range(N):
    for j in range(1, int(child[i][0]) + 1):
        favorite[int(child[i][j]) - 1] += 1


print(favorite.count(N))

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

syoki = [] 
for i in range(1,m+1):
    syoki.append(i)
nasi = []
for i in arrk:
    for j in syoki:
        
        if j not in i[1:]:
            nasi.append(j)
            

print(len(syoki)-len(set(nasi)))

Solution (Python):
import numpy as np


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

    flag = np.array([1]*M)

    for l in KA:
        tmp = np.array([0]*M)
        for i in range(1, l[0]+1):
            tmp[l[i]-1] = 1
        flag *= tmp

    print(sum(flag))


if __name__ == "__main__":
    main()

Solution (Python):

"""
Created on Mon May  4 20:56:04 2020
"""

import sys


sys.setrecursionlimit(10 ** 9)


mod = 10**9+7


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

foods = [0 for _ in range(M)]
for i in range(N):
    for j in range(1,len(A[i])):
        foods[A[i][j]-1] += 1


ans = 0
for f in foods:
    if f == N:
        ans += 1
print(ans)

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

Solution (Python):
n, m = map(int, input().split())
menu = set(range(1, m+1))
for _ in range(n):
  l = list(map(int, input().split()))
  l.pop(0)
  l = set(l)
  menu = menu & l

print(len(menu))

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

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

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

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

Solution (Python):
import numpy as np
n, m = map(int, input().split())
k = [0] * n
for i in range(n):
    k[i] = list(map(int, input().split()))

b = np.zeros((n, m))
for i in range(n):
    w = k[i]
    for j in range(1, len(w)):
        b[i, int(w[j])-1] = 1
print(sum(b.sum(axis=0) == n))

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

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

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
KA = [LIST() for _ in range(N)]

S = set(KA[0][1:])
for i in range(1, N):
	S = S & set(KA[i][1:])

print(len(S))

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

Solution (Python):


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

for i in range(N):
    KA = list(int(x) for x in input().split())
    for j in range(1, len(KA)):
        F[KA[j]] += 1

print(F.count(N))

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

Solution (Python):
n,m=map(int,input().split())
A=list(map(int,input().split()))
A=A[1:]
for i in range(n-1):
    sub=A
    temp=list(map(int,input().split()))
    A=[]
    for j in range(0,len(sub)):
        if sub[j] in temp[1:]:
            A.append(sub[j])
print(len(A))

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7


n,m=MI()
ans=0
vote=[0 for i in range(m)]
likes=[]
for i in range(n):
    likes.append(LI())

for j in range(len(likes)):
    for k in range(1,len(likes[j])):
        
        vote[likes[j][k]-1]+=1

for v in vote:
    if v==n:
        ans+=1
print(ans)

Solution (Python):
import copy
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.pop(0)
for i in range(n-1):
  t=list(map(int,input().split()))
  k=t.pop(0)
  b=copy.deepcopy(a)
  for j in range(0,len(a)):
    if not b[j] in t:
      a.remove(b[j])
print(len(a))

Solution (Python):
N,M = map(int,input().split())
K=[]
ans=0
for _ in range(N):
  K+=input().split()[1:]
S=set(K)
for s in S:
  if K.count(s)==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())
ka=[list(map(int,input().split())) for _ in range(n)]
ans=[0 for _ in range(m)]

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

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

cnt = [0]*(m+1)

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

print(cnt.count(n))

Solution (Python):
import numpy as np
import sys

input = sys.stdin.readline

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

cnt = [1]*(M+1)
cnt[0] = 0

res = M
for _ in range(N):
    a = list(map(int,input().split()))
    a = a[1:]
    for x in range(1,M+1):
        if x not in a and cnt[x] == 1:
            cnt[x] = 0
            res-=1

print(res)

Solution (Python):

import collections
n, m = map(int, input().split())
l = []
ans = 0
for _ in range(n):
    l.extend(list(map(int, input().split()))[1:])
c = collections.Counter(l)
for k in c:
    if c[k] == n: ans += 1
print(ans)

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

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

print(cnt)

Solution (Python):
n, m = map(int, input().split())
A = set({i for i in range(1,m+1)})
for i in range(n):
    row = list(map(int, input().split()))
    k = row[0]
    A_i = row[1:]
    A = A & set(A_i)
print(len(list(A)))

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


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

print(Al.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())
arr = [0]*(m+1)
for i in range(n):
  s = list(map(int, input().split()))
  for j in range(1,s[0]+1):
    arr[s[j]] += 1
print(arr.count(n))

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

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

Solution (Python):
n, m = map(int,input().split())
p = []
for i in range(n):
    p.append(list(map(int,input().split())))
s = set()
for i in range(p[0][0]):
    s.add(p[0][i+1])

for i in range(1,n):
    kar = set()
    for j in range(p[i][0]):
        kar.add(p[i][j+1])
    s = s & kar

print(len(s))

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

print(cnt)

Solution (Python):
import collections


def solve():

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

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

    
    c = collections.Counter(a)
    ans = 0
    for val in c.values():
        
        if val == N:
            ans += 1

    print(ans)


if __name__ == "__main__":
    solve()

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

ans = set(K[0])
for ki in K[1:]:
    ans = ans.intersection(ki)

print(len(ans))

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

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

Solution (Python):
n, m = map(int, input().split())
all = {int(i) for i in range(1, m + 1)}
for _ in range(n):
    k, *i_th = map(int, input().split())
    all &= set(i_th)
print(len(all))

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

l = list()

for a in range(0, N):
    L = list(map(int, input().split()))
    L.pop(0)
    l.append(L)

count = [0]*(M)

for a in l:
    for b in a:
        count[b-1] += 1

print(len(list(filter(lambda x: x == N, count))))

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

Solution (Python):

def inputlist(): return [int(k) for k in input().split()]

N,M = inputlist()
ans = [0]*(M+1)
c =0
for i in range(N):
    A = inputlist()
    K = A[0]
    Aa = A[1:]
    for j in range(K):
        ans[Aa[j]] +=1
for i in range(1,M+1):
    if ans[i] == N:
        c+=1
print(c)

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

Solution (Python):
from collections import Counter
N , M = (map(int , input().split()))
A = [list(map(int, input().split())) for i in range(N)]
kaku_list = []
for i in A:
    for j in range(i[0]):
        kaku_list.append(i[j+1])
ct = dict(Counter(kaku_list))
ans = 0
for v in ct.values():
    if N == v:
        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):
import numpy as np
N,M=map(int, input().split())
tabelist = np.zeros(M)
for i in range(N):
  c=list(map(int, input().split()))
  for k in range(1,c[0]+1):
    tabelist[c[k]-1] = tabelist[c[k]-1] + 1

print(len([1 for x in tabelist if x==N]))

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

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

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

answer_set=set(range(1,M+1))
for i in range(N):
  k,*alist=map(int,input().split())
  answer_set&=set(alist)
  
print(len(answer_set))

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
n,m= map(int,input().split())
A = [input().split() for i in range(n)]

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

Solution (Python):
from collections import deque, Counter
N, M = map(int, input().split())

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

ans = list(L[0][1:len(L[0])])
for i in range(N - 1):
    for j in range(L[i][0]):
        if L[i][j + 1] in L[i + 1][1:L[i + 1][0] + 1]:
            ans.append(L[i][j + 1])

c = Counter(ans)
count = 0
for k, v in c.items():
    if (v == N):
        count += 1
    else:
        continue
print(count)

Solution (Python):
def Foods_Loved(n, m, kal):

    ans = 0

    for i in range(1, m+1):
        flag = True
        for ka in kal:
            if i not in ka[1:]:
                flag = False
        if flag:
            ans += 1

    return ans

def main():
    n, m = map(int, input().split())
    kal = [list(map(int, input().split())) for i in range(n)]
    print(Foods_Loved(n, m, kal))

if __name__ == '__main__':
    main()

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

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

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

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

c = Counter(a)

ans = 0
for k, v in c.most_common():
    if v == n:
        ans += 1
    else:
        break
print(ans)

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

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    N, M = map(int, readline().split())
    S = set(i for i in range(1,M+1))
    for _ in range(N):
        S &= set(list(map(int, readline().split()))[1:])
    print(len(S))


if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

if __name__ == '__main__':
    main()

Solution (Python):

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

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

count = 0
for i in range(len(t)):
    if t[i] == n:
        count += 1
print(count)

Solution (Python):

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

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

count = 0

for i in range(len(t)):
    if t[i] == n:
        count += 1

print(count)

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
answer = set(range(1, M+1))
for _ in range(N):
    k, *A = lr()
    s = set(A)
    answer &= s

print(len(answer))

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


favorites = set(KA[0])
for KAi in KA:
    favorites = favorites & set(KAi)

number_of_common_favorites = len(favorites)

print(number_of_common_favorites)

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    ans = [1] * M
    for _ in range(N):
        A = list(map(lambda x: int(x) - 1, input().split()))[1:]
        for a in range(M):
            if a not in A:
                ans[a] = 0
    print(sum(ans))


if __name__ == '__main__':
    main()

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

k, *a = [int(i) for i in input().split()]

a = set(a)

for _ in range(n-1):
  _, *b = [int(i) for i in input().split()]
  a = a & set(b)
print(len(a))

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

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


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

print(count)

Solution (Python):
N,M=map(int,input().split())
lst = [0] * M
for i in range(N):
  s = input().rstrip().split(' ')
  num = int(s[0])
  for j in range(1, num+1):
    lst[int(s[j])-1] += 1
length = len(lst)
count = 0
for k in range(length):
  if lst[k] == N:
    count += 1
print(count)

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

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

print(ans.count(N))

Solution (Python):
n, m = map(int, input().split())
servey = []
for i in range(n):
    k_a = list(map(int, input().split()))
    servey.append(k_a)
for j in servey:
    del j[0]
loves = []
for x in range(1, m+1):
    count = 0
    for y in servey:
        if x in y:
            count+=1
        loves.append(count)
food_count = 0     
for z in loves:
    if z == n:
        food_count += 1

print(food_count)

Solution (Python):
from collections import Counter
n,m = map(int,input().split())
input_lines = [int(j) for i in range(n) for j in input().split()[1:]]

menu_dic = Counter(input_lines)
print(sum(value==n for key,value in menu_dic.items()))

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

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

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

l=[]
for i in range(N):
  a=list(map(int,input().split()))
  a.pop(0)
  l.append(a)
  


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

Solution (Python):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    R = [set(il()[1:]) for _ in range(N)]
    ret = R[0]
    for r in R:
        ret &= r
    print(len(ret))


if __name__ == '__main__':
    main()

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

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

d = [0]*m
for _ in range(n):
    flag = True
    for a in map(int, input().split()):
        if flag:
            flag = False
            continue
        d[a-1] += 1

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

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

Solution (Python):
n,m = map(int,input().split())
k = []
a = []
while True:
  try:
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    a.append(tmp[1:])
  except:
    break

counter = [0]*m
for i in a:
  for j in i:
    counter[j-1] +=1

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