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())
data = []
for i in range(N):
	temp = list(map(int, input().split()))
	data.extend(temp[1:])
ans = 0

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

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

for i in range(len(lst)):
    for j in range(len(lst[i])):
        cnt_idx = lst[i][j]
        cnt_lst[cnt_idx] += 1

for cnt in cnt_lst:
    if cnt == n:
        ans += 1
print(ans)

Solution (Python):


from sys import stdin

N, M = list(map(int, stdin.readline().split()))

kind = 0
box = []
for i in range(M):
    box.append(0)

for j in range(N):
    box1 = list(map(int, stdin.readline().split()))
    for i in range(box1[0]):
        box[box1[i+1]-1] += 1
count = 0

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

print(count)

Solution (Python):


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

cnts = [0 for _ in range(m + 1)]

for _ in range(n):
    for like_no in map(int, input().strip().split()[1:]):
        cnts[like_no] += 1

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

print(ans)

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

if N == 1:
    print(res[0][0])
    exit()

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



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

print(count)

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

B = []
for j in range(n):
    for k in range(A[j][0]):
        B.append(A[j][k+1])

score = 0
for l in range(m+1):
    if B.count(l) == n:
        score += 1

print(score)

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

def chkprint(a):
	a_name = ''
	for k, v in globals().items():
		if id(v) == id(a):
			a_name = k
			break
	print(a_name+' = '+str(a), file=sys.stderr)

def mt(f):
	import time
	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		print(e - s, 'sec', file=sys.stderr)
		return ret
	return wrap

@mt
def slv():
	
	
	return 
	
N, M = [int(i) for i in input().split()]
K = [[int(i) for i in input().split()] for _ in range(N)]

count = 0
for i in range(1, M+1):
	a = True
	for Ki in K:
		if not i in Ki[1:]:
			a = False
	if a:
		count += 1

print(count)

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

Solution (Python):
n, m = list(map(int, input().split()))
se = set(range(1, m + 1))
for _ in range(n):
    x = se - set(list(map(int, input().split()))[1:])
    se -= x

print(len(se))

Solution (Python):
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

n,m = reads()
a = []
r = []
for i in range(n):
    a.append(reads())
for i in range(n):
    for j in range(1,a[i][0]+1):
        r.append(a[i][j])
ans = 0
for i in set(r):
    if r.count(i) == n:
        ans += 1
print(ans)

Solution (Python):
n,m=map(int,input().split())
x=[]
answer=0
for i in range(n):
    x.append(list(map(int,input().split())))
    del x[i][0]
for i in range(m):
    cnt=0
    for j in range(n):
        if i+1 in x[j]:
            cnt+=1
        else:
            break
    if cnt==n:
        answer+=1
print(answer)

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

Solution (Python):
n,m=list(map(int,input().split(" ")))
ka=[]
for i in range(n):
    ka.append(list(map(int,input().split(" "))))
for i in range(n):
    ka[i].pop(0)
counter=0
i=1
while i<=m:
    j=0
    while j<=n-1:
        if i in ka[j]:
            j+=1
        else:
            break

        if j==n:
            counter+=1
    i+=1
print(counter)

Solution (Python):


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

for i in range(0, n):
    tmp = input().split(' ')
    food_loved.append(set(tmp[1:len(tmp)]))

result = food_loved[0]

for i in range(1, n):
    result = result & food_loved[i]

print(len(result))

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

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

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

Solution (Python):


import collections

N,M = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(N)]
tmp=[]
for i in lst:
    l = i[1:]
    for p in l:
        tmp.append(p)

ct = collections.Counter(tmp)
values, counts = zip(*ct.most_common())
ans = 0
for i in counts:
    if i == N:
        ans+=1
print(ans)

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

persons = [input() for i in range(N)]

cnt = [0 for i in range(M)]

for i_person in persons:
    l = list(map(int, i_person.split(" ")))
    

    for f in l[1:]:

        cnt[f-1] += 1

print(sum(list(map(lambda x:x==N, cnt))))

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

A = [flatten for inner in A for flatten in inner[1:]]

import collections
A_cnt = collections.Counter(A)
print(sum([l[1]==N for l in A_cnt.most_common()]))

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

Solution (Python):

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

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

A = []


for i in range(N):
    A.append(list(map(str, input().split())))
    del A[i][0]

if N != 1:
    ans = set(A[0]) & set(A[1])

if N >= 3:
    for i in range(2,N):
        ans = ans & set(A[i])

if N >= 2:
    print(len(ans))
else:
    print(len(A[0]))

Solution (Python):
(N ,M) =  (int(i) for i in input().split())
A =set(range(1,M+1))

for n in range(N):
	A = A.intersection(set([int(i) for i in input().split()][1:]))

print(len(A))

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


for i in range(N):
    
    I = input().split()
    
    K = int(I[0])
    for j in range(K):
        index = int(I[j+1])
        like[index - 1] += 1
    

C = like.count(N)

print(C)

Solution (Python):
N,M = map(int,input().split())
for i in range(N):
    if i == 0:
        lista = list(map(int,input().split()))
        del lista[0]
    else:
        listb = list(map(int,input().split()))
        del listb[0]
        lista = list(set(lista) & set(listb))
print(len(lista))

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

ma = K.index(max(K))

kinds = 0
for j in range(K[ma]):
    f = 0
    for i in range(N):
        if A[ma][j] in A[i]:
            f += 1
    if f == N:
        kinds += 1
print(kinds)

Solution (Python):
a = list(map(int, input().split()))
l = []
ans = 0
for i in range(a[0]):
    l.extend(list(map(int, input().split()))[1:])

for i in range(a[1]):
    if l.count(i + 1) == a[0]:
        ans = ans + 1
print(ans)

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

for k in range(0, n):
    a = [int(i) for i in input().split(" ")]
    for j in range (1, a[0] + 1):
        c[a[j] - 1] += 1

s = 0
for i in range(0, m):
    if c[i] == n:
        s += 1

print(s)

Solution (Python):
import numpy as np
N, M =map(int,input().split())
search = np.zeros(M+1)
for i in range(N):
    K = list(map(int,input().split()))
    for j in range(1,K[0]+1):
        search[K[j]]+=1
place = np.where(search==N)
print(len(place[0]))

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

print(len(set.intersection(*map(set,lis))))

Solution (Python):
a,b=map(int,input().split())
L=[]
for s in range(a):
  x=input().split()[1:]
  L=list(set(L)&set(x))
  if s==0:
    L=x
print(len(L))

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

for i in range(n):
    list1[i]=list(map(int, input().split()))  
    list1[i].pop(0)

ans = 0

for i in range(m):
    check = 0
    for j in range(n):
        if not i+1 in list1[j]:
            check =1
            break
    
    if check == 0:
        ans += 1


print(ans)

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

set_prev = set(like_foods[0])

for i in like_foods:
    set_prev = set_prev & set(i)
    
print(len(set_prev))

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

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

print(ans)

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

count = [0] * M

for n in range(N):
    A = list(map(int, input().split()))

    for a in A[1:]:
        count[a-1] += 1

ans = 0

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

print(ans)

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

Solution (Python):
N,M=map(int, raw_input().split())
A=[ 1 for i in range(M+1) ] 

for i in range(N):
	X=map(int, raw_input().split())
	for j in range(1,M+1):
		if j not in X[1:]:
			A[j]&=0

print sum(A[1:])

Solution (Python):
import collections
n,m = map(int,input().split())
k_list = []
for _ in [0]*n:
    k_list.extend([int(i) for i in input().split()[1:]])
col = collections.Counter(k_list)
count = 0
for k,v in col.most_common():
    if v == n:
        count += 1
print(count)

Solution (Python):
N, M = map(int,input().split())
s_a = {i + 1 for i in range(M)}
for i in range(N):
  l = list(map(int,input().split()))
  a = set(l[1:])
  s_a = s_a.intersection(a)
print(len(s_a))

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

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

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

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

print(ans)

Solution (Python):
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())
common = set(range(1,M+1))
for _ in range(N):
    answer = tuple(li())
    favs = set(answer[1:])
    common = common.intersection(favs)
print(len(common))

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

print(Kind.count(N))

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



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

print(ans)

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])
count=0
for i in range(M):
    if X.count(i+1)==N:
        count+=1
print(count)

Solution (Python):
import collections
n,k = map(int, input().split())
l=[]
for i in range(n):
    x = list(map(int, input().split()))
    l+=x[1:]
c = collections.Counter(l)
s=0
for i in c.most_common():
    
    if n == i[1]:
        s+=1
print(s)

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

for i in range(n):
  k[i] = k[i][1:]

ary = [1] * m
for i in range(n):
  for j in range(m):
    if(not j+1 in k[i]):
      ary[j] = 0
print(sum(ary))

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

Solution (Python):
import sys
from operator import itemgetter
import collections


def r(n, m, kl):
    nc = 0
    al = []
    for k in kl:
        al.extend(k[1:])
    c = collections.Counter(al)
    for v in c.values():
        if v == n:
            nc += 1
    return nc

def main():
    input = sys.stdin.readline
    n, m = list(map(int, input().split()))
    kl = [tuple(map(int, input().split())) for _ in range(n)]

    print(r(n, m, kl))


if __name__ == '__main__':
    main()

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

questionary = [0 for i in range(m + 1)]

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

summary = list(map(lambda x:x == n, questionary))
print(sum(summary))

Solution (Python):

from collections import defaultdict

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


result = defaultdict(list)

for i in range(N):
    data = list(map(int, input().split()))
    K = data[0]
    data = data[1:]
    data = [d-1 for d in data]
    result[i]=data


count = 0
for food in range(M):
    break_flag = False
    for i in range(N):
        if not food in result[i]:
            break_flag = True
            break
    else:
        count+=1

print(count)

Solution (Python):


import numpy as np

def solve():
    N, M  = map(int, input().split())
    A = set.intersection(*(set(list(map(int, input().split()))[1:]) for _ in range(N)))
    res = len(A)

    return str(res)
if __name__ == '__main__':
    print(solve())

Solution (Python):
from collections import Counter

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

all_likes = []
for i in range(N):
    K,*As = map(int,input().split())
    all_likes.extend(As)

print(len([i for i in Counter(all_likes).values() if i==N]))

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

tmp = lst[0]
for i in range(1,N):
  tmp = tmp & lst[i]

ans = len(tmp)
print(ans)

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

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

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

ans = list()
for _ in range(1,m+1):
    if all(_ in a[i] for i in range(0,n)):
        ans.append(_)

print(len(ans))

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

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

all_suki_e = 0
for e in range(1, M + 1):
    for sukis in suki_lists:
        
        if e in sukis:
            pass
        else:
            
            break
    else:
        
        all_suki_e += 1

print(all_suki_e)

Solution (Python):
n, m = [int(_) for _ in input().split()]
s = set(range(1, m + 1))

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

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

if __name__ == '__main__':
	main()

Solution (Python):
import numpy as np

N,M = map(int ,input().split())
ans = np.array([0 for _ in range(M+1)])
for i in range(N):
    S = list(map(int,input().split()))
    for s in S[1:]:
        ans[s] += 1
cnt = 0
for a in ans:
    if a == N:
        cnt += 1

print(cnt)

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

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

count = 0
for item in a_list:
    if item == n:
        count += 1

print(count)

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

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

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

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

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

for i in range(1, n):
    t = set(input().split()[1:])
    s = s & t
    
print(len(s))

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

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

foods = [0] * M
num = 0
for like in like_list:
    for elem in like[1:]:
        foods[elem-1] += 1
        if foods[elem-1] == N:
            num += 1

print(num)

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

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

menu = [0 for i in range(M)]

for i in range(N):
    love = list(map(int,input().split()))
    for idx,t in enumerate(love):
        if idx == 0:
            continue
        menu[t-1] += 1

ans = 0
for i in menu:
    if i == N:
        ans += 1
print(ans)

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

leftover = None
for i in range(n):
    k_a_list = list(map(int, input().split()))
    if i == 0:
        leftover = k_a_list[1:]
    else:
        k = k_a_list[0]
        leftover = [a for a in k_a_list[1:] if a in leftover]
    if leftover == []:
        print(0)
        exit()

print(len(leftover))

Solution (Python):
N, M = map(int, input().split())
K = []
A = []
for n in range(N):
    INPUT = list(map(int, input().split()))
    K.append(INPUT[0])
    A.append(INPUT[1:])
intersection=set(A[0])
for a in A:
    intersection=intersection&set(a)
print(len(intersection))

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




foods = list(range(1, m+1))

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

    new_foods = []
    for a in ans:
        if a in foods:
            new_foods.append(a)

    foods = new_foods

print(len(foods))

Solution (Python):
from sys import stdin

n, m = list(map(int, stdin.readline().rstrip().split()))
stack = set(range(1, m+1))
for i in range(n):
	a = list(map(int, stdin.readline().rstrip().split()))
	k = a.pop(0)
	stack = set(a) & stack

print(len(stack))

Solution (Python):
N, M = map(int, input().split())
ans = [0] * 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):






def main():
    N, M = [int(i) for i in raw_input().strip().split(' ')]
    A = []
    for _ in range(N):
        a = [int(i) for i in raw_input().strip().split(' ')][1:]
        A.append(a)
    Hantei = [True for _ in range(M)]

    for a in A:
        
        for i in range(1, M+1):
            if i in a:
                pass
            else:
                Hantei[i-1] = False

    
    print Hantei.count(True)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

NM = list(map(int, input().split()))

count_num = np.zeros((NM[1], 1))

for i in range(NM[0]):
    num = list(map(int, input().split()))
    del num[0]
    for j in num:
        count_num[j-1] += 1

print(np.sum(count_num == NM[0]))

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

A = [set()]*N
anns = set([ i+1 for i in range(M)])
for i in range(N):
    tmp = [int(n) for n in input().split()]
    A[i] = set(tmp[1:])
    anns = anns & A[i]
print(len(anns))

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

Solution (Python):
import collections

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

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

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

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

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

ans_list = list(map(int, input().split()))[1:]
for _ in range(1, n):
    a = list(map(int, input().split()))[1:]
    tmp_list = []
    for ans in ans_list:
        if ans in a:
            tmp_list.append(ans)
    ans_list = tmp_list

print(len(ans_list))

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

ans = 0
tmp = 0
for i in range(31):
    for j in arr:
        if i in j:
            tmp += 1
        else:
            break
    if tmp == n:
        ans += 1
    tmp = 0

print(ans)

Solution (Python):
import collections
N,M = list(map(int,input().split()))
L=[]
def flatten(nested_list):
    return [e for inner_list in nested_list for e in inner_list]


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

cnter=collections.Counter(flatten(L))
print(len([i[0] for i in cnter.items() if i[1] >= N]))

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

Solution (Python):

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

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

cnt = {}
for i in range(1, M+1):
    cnt[i] = 0

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

Solution (Python):
import numpy as np

n_person, n_food = map(int, input().split(' '))

array = [1] * n_food

for i in range(n_person):
    li = list(map(int, input().split(' ')))
    li_sub = np.zeros(n_food)
    for j in li[1:]:
        li_sub[j-1] = 1
    array = array * li_sub

print(int(np.sum(array)))

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

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

ans = 0
for i in range(1, m+1):
    val = True
    for l in lst:
        if i not in l:
            val = False
    if val:
        ans += 1
print(ans)

Solution (Python):

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

food = [0] * M

for i in range(0,N):
    Ks =  list(map(int, input().split()))
    K = Ks[0]
    for j in range(1,K+1):
        food[Ks[j]-1] += 1

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

print(cnt)

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  A = set(list(range(1, M+1)))
  for _ in range(N):
    B = set(list(map(int, input().split()))[1:])
    A = A & B
  print(len(A))


if __name__ == '__main__':
  main()

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

ans = set([x for x in range(1,M+1)])

for i in range(N):
    l = [int(x) for x in input().split()]
    l.pop(0)
    l = set(l)

    ans = ans & l

print(len(ans))

Solution (Python):
import numpy as np
N, M = map(int, input().split())

num_class = []
foodlist = np.zeros(M)

for n in range(N):
    tmplist = list(map(int, input().split()))
    num_class.append(tmplist[0])
    for i in range(tmplist[0]):
        foodlist[tmplist[i+1]-1] += 1

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

print(count)

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

Solution (Python):
from collections import Counter
import numpy as np
N, M = (int(i) for i in input().split())

A=[]
for i in range(N):
    A_tmp = np.array([int(i) for i in input().split()[1:]])
    A.extend(A_tmp)

c = Counter(A)
values, counts = zip(*c.most_common())
print(np.sum(np.array(counts)==N))

Solution (Python):
N,M = map(int,input().split())
Likes = [N for _ in range(M)] 
for _ in range(N): 
    temp = [int(i) for i in input().split()]    
    for k in range(1,len(temp)):
        Likes[temp[k]-1] -= 1
print(Likes.count(0))

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

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

s = [0 for i in range(m)]

for i in range(n):
    konomi = input().split()
    for j in range(len(konomi)-1):
        s[int(konomi[j+1])-1] += 1

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

print(sum)

Solution (Python):
import collections
def main():
	n, m = map(int, input().split())
	count = collections.defaultdict(int)
	for _ in range(n):
		nums = list(map(int, input().split()))
		for i in range(nums[0]):
			count[nums[i+1]] += 1
	ans = 0
	for v in count.values():
		if v == n:
			ans += 1

	print(ans)

if __name__ == '__main__':
	main()

Solution (Python):

N, M = list(map(int, input().split()))
l = [0 for _ in range(M)]
for _ in range(N):
    s = list(map(int, input().split()))
    for i in s[1:]:
        l[i - 1] += 1
ans = 0
for i in l:
    if i == N:
        ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split(' '))
food = set(range(1, m+1))
for i in range(n):
    li = [int(x) for x in input().split(" ")]
    ki = li[0]
    ai = li[1:]
    food = food.intersection(ai)
print(len(food))

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

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

res = A[0]
for i in range(1,N):
    res = res & A[i]

print(len(res))

Solution (Python):


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

for i in range(N):
    l = [int(i) for i in input().split()]
    for a in l[1:]:
        cnt[a] += 1
res = sum([1 for c in cnt if c == N])
print(res)

Solution (Python):

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

s = set(range(1, M+1))
for i in range(N):
    t = set(list(map(int, input().split()))[1:])
    s = s.intersection(t)

print(len(s))

Solution (Python):
N, M = map(int, input().split())
suki_list = list(map(int, input().split()))
suki_list = suki_list[1:]
suki_set = set(suki_list)
for i in range(N-1):
    suki_list = list(map(int, input().split()))
    suki_list = suki_list[1:]
    remove_list = []
    for num in suki_set:
        if num not in suki_list:
            remove_list.append(num)
    for i in remove_list:
        suki_set.remove(i)

print(len(suki_set))

Solution (Python):
n, m = map(int, input().split())
foods = [n for food_syurui in range(m+1)]
for i in range(n):
	question = list(map(int, input().split()))
	for syurui in question[1:]:
		foods[syurui] -= 1
print(foods.count(0))

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

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

allset = set()
for i in range(n):
    l_raw = input().split()
    l_new = l_raw[1:]
    if i != 0:
        allset = allset & set(l_new)
    else:
        allset = set(l_new)


print(len(allset))