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())
Fav = [list(map(int,input().split()))[1:] for i in range(N)]
Sum = 0
for i in range(M):
    Flag = True
    for j in range(N):
        if not i+1 in Fav[j]:
            Flag = False
    if Flag:
        Sum += 1
print(Sum)

Solution (Python):
n, m = map(int, input().split())
love = set(range(1, m + 1))
for _ in range(n):
    k, *aaa = map(int, input().split())
    love.intersection_update(aaa)
print(len(love))

Solution (Python):
N,M=map(int,input().split())
series=[[] for N in range(N)]
for n in range(N):
	series[n]=list(map(int,input().split()))
ans = 0
for m in range(1,M+1):
	for n in range(N):
		if m not in series[n][1:]:
			break
	else:
		ans += 1
print(ans)

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

A = [0 for _ in [0]*M]

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

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

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

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

m = {}

for row in A:
    cnt = 0
    for num in row:
        cnt += 1
        if cnt == 1:
            continue
        m.setdefault(num, 0)
        m[num] += 1

cnt = 0
for num in m.values():
    if num == N:
        cnt += 1
print(cnt)

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

Solution (Python):
import numpy as np

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

array = np.zeros([n,m])
for k1, i in enumerate(lst):
    for k2, j in enumerate(i):
        array[k1][j-1] += 1

print(sum(array.sum(axis=0)==n))

Solution (Python):
N, M = map(int, input().split())
likes = [[int(i) for i in input().split()] for _ in range(N)]
seki = {}
for i in range(N):
    if seki == {}:
        seki = {likes[i][j] for j in range(1, likes[i][0]+1)}

    tag={likes[i][j] for j in range(1, likes[i][0]+1)}
    seki= seki & tag

print(len(seki))

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

d = defaultdict(int)
n, m = map(int, input().split())
for i in range(n):
    a = list(map(int, input().split()))
    count = 0
    for j in a:
        if count == 0:
            count += 1
            continue
        d[j] += 1
count = 0
for i in d:
    if (d[i] == n):
        count += 1

print(count)

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

l = []
m = []
for j in range(n):
    k,*a = [int(i) for i in input().split()]
    l.append(a)
    m.append(k)

count = 0
for i in l[0]:
    flag = 0
    for j in range(len(l)):
        if i not in l[j]:
            flag = 1

    if flag == 0:
        count += 1
print(count)

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

Solution (Python):

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

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


    tmp = [i for i in range(1,m+1)]
    for i in lst:
        tmp = set(tmp) & set(i)

    print(len(tmp))


if __name__ == "__main__":
        main()

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

Solution (Python):


N, M = [int(x) for x in input().strip().split()]

a = set(str(x) for x in range(1, M+1))
for i in range(N):
    a = a & set(input().strip().split()[1:])
print(len(a))

Solution (Python):
a,b=list(map(int,input().split()))
L=[]
for i in range(a):
    L.append(list(map(int,input().split())))

l={i for i in range(1,b+1)}    
for i in range(a):
    l=l&set(L[i][1:])
print(len(l))

Solution (Python):

"""
Created on Sat Feb 16 19:31:10 2019
ABC118B
@author: maezawa
"""

n, m = list(map(int, input().split()))
a0 = list(map(int, input().split()))
k = a0.pop(0)
common = set(a0)
for i in range(1, n):
    ai = list(map(int, input().split()))
    k = ai.pop(0)
    common = common & set(ai)
    
print(len(common))

Solution (Python):
n,m=map(int,input().split())
K=[]
for _ in range(n):
    A=list(map(int,input().split()))
    A.pop(0)
    K.append(A)
ans=0
for i in range(1,31):
    flag=True
    for j in range(n):
        if i not in K[j]:
            flag=False
    if flag:
        ans+=1
print(ans)

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

result = set([t for t in range(1,M+1)])


for n in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    result &= set(A)
    

print(len(result))

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

Solution (Python):


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

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

l = []

for i in range(N):
    A = [int(x) for x in input().split()]

    for j in range(1, A[0] + 1):
        l.append(A[j])

ans = 0

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

print(ans)

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

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

    ans = 0
    for y in x:
        if sum(y) == N:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
dic = {}
dic[0] = 1
N, M = map(int, input().split())
for i in range(N):
  for j, a in enumerate(list(map(int, input().split()))):
    if j == 0:
      continue
    if dic.get(a):
      dic[a] += 1
    else:
      dic[a] = 1
cnt = 0
for i in dic.keys():
  if i == 0:
    continue
  if dic[i] == N:
    cnt += 1
print(cnt)

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

cnt = 0
for i in range(m):
    flag = True
    for a in A:
        if i + 1 not in a:
            flag = False
    if flag:
        cnt += 1

print(cnt)

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

dict = {}
for n in range(N):
    k_a = [int(_) for _ in input().split()]
    for k in range(k_a[0]):
        if k_a[k+1] in dict:
            dict[k_a[k+1]] += 1
        else:
            dict[k_a[k+1]] = 1

count = 0
for key in dict:
    if dict[key] == N:
        count += 1

print(count)

Solution (Python):


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

ans_list=[i+1 for i in range(M)]

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

print(len(ans_list))

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

Solution (Python):
n, m = [int(x) for x in input().split()]
cnt_list = [0] * m
for idx in range(n):
  for k in [int(x) for x in input().split()][1:]:
    cnt_list[k-1] += 1
print(sum([1 if x==n else 0 for x in cnt_list]))

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

l = []
for _ in range(M):
    l += [0]
aa=[]
for i in range(N):
    aa.append([int(i) for i in input().split()])
    aa[i].pop(0)

for line in aa:
    for i in line:
        l[i - 1] += 1

ans = 0
for index, s in enumerate(l):
    if s == N:
        ans += 1

print(ans)

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

food_list = [list(map(int, input().rstrip().split())) for _ in range(n)]
answer = [0]*m

for food in food_list:
    food.pop(0)
    for tmp in food:
        answer[tmp-1] += 1

print(answer.count(n))

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

Solution (Python):
def solve():
  N, M = map(int, input().split())
  l = [int(i) for i in input().split()]
  l.pop(0)
  s = set(l)
  for i in range(N - 1):
    l = [int(i) for i in input().split()]
    l.pop(0)
    s = s & set(l)
  return len(s)

print(solve())

Solution (Python):
import numpy as np

(N,M) = map(int,input().split())
B = np.ones(M,dtype=np.int)

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

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

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

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

aaa = []
for a in aa:
    for ai in a:
        aaa.append(ai)
ans=0
for i in range(m):
    if aaa.count(i+1)==n:
        ans+=1
print(ans)

Solution (Python):
N,M = [int(_) for _ in input().split()]
K = []
c = 0
for i in range(1,N+1):
    I = [int(_) for _ in input().split()]
    K = K + I[1:]
for j in range(1,M+1):
    if K.count(j)==N:
        c +=1
print(c)

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

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

l = []
for i in KA:
    l.append(i[1:])
    
ans = set(l[0])

for i in range(N):
    ans = ans & set(l[i])

print(len(ans))

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

Solution (Python):
people, foods = map(int, input().split(' '))
buckets = [0] * (foods + 1)
for i in range(people):
  a = list(map(lambda x: int(x), input().split(' ')))
  favorite_foods = a.pop(0)
  for food_num in a:
    buckets[food_num] += 1

count = 0
for food in buckets:
  if food == people:
    count += 1

print (count)

Solution (Python):
import sys
input = sys.stdin.readline
n,m = input().split()
n = int(n)
m = int(m)
list = [[] for i in range(n)]
for i in range(n):
    list[i] = input().split()
    for j in range(int(list[i][0])):
        list[i][j] = int(list[i][j+1])
ans = 0
for i in range(m):
    flag = 1
    for j in range(n):
        if i+1 not in list[j]:
            flag = 0
    if flag == 1:
        ans += 1
print(ans)

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

inputs = [[i for i in input().split()] for _ in range(N)]

ans = set(inputs[0])
for item in range(N):
    ans = ans & set(inputs[item][1:])

print(len(ans))

Solution (Python):
import collections


def main():
    n, m = (int(z) for z in input().split())
    ctr = collections.Counter()
    for _ in range(n):
        xs = [int(z) for z in input().split()][1:]
        ctr.update(xs)
    print(sum(v == n for k, v in ctr.items()))


if __name__ == "__main__":
    main()

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

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    food_list = [set(map(int, input().split()[1:])) for _ in range(N)]

    ans = food_list[0]
    for idx in range(len(food_list) - 1):
        ans = ans & food_list[idx + 1]
    print(len(ans))


if __name__ == '__main__':
    main()

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

Solution (Python):
n,m = [int(i) for i in input().split()]
like = {i:True for i in range(1,m+1)}
for i in range(n):
  a = [int(i) for i in input().split()[1:]]
  s = list(like.keys())
  for i in s:
    if i not in a:
      like.pop(i)

print(len(like.keys()))

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

L = [ list(map(int, input().split())) for i in range(N)]
ans = 0
res = [0 for i in range(M)]

for l in L:
    for i in range(len(l)):
        if i != 0:
            res[l[i]-1] += 1
        
for i in range(M):
    if res[i] == N:
        ans += 1
        
print(ans)

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

for i in range(N):
  s = set(list_n[i][1:])
  if i == 0:
    s_inter = s
  else:
    s_inter = s_inter & s

print(len(s_inter))

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


count = m*[0]
for i in a:
    tmp = 0
    for j in range(m):
        if(i[j] == 1): count[j] += 1


ans = 0
for i in count:
    if(i == n): ans += 1

print(ans)

Solution (Python):
N , M = map(int,input().split())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    tmp =l.pop(0)
    L.append(l)
cnt = 0
for i in range(1,1+M):
    for x in L:
        if i in x:
            pass
        else:
            break
    else:
        cnt += 1
print(cnt)

Solution (Python):


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

likeList = []
for i in range(N):
    myList = list(map(int, input().split()))
    likeList += myList[1:]
    
ans = 0
for i in range(M):
    if likeList.count(i + 1) == N:
        ans += 1
        
print(ans)

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

typ = set(range(1, M+1))

for i in range(N):
    A = map(int, raw_input().split())[1:]
    typ = typ & set(A)

print len(typ)

Solution (Python):
N, M = map(int, input().split())
lst = input().split()
s1 = set(lst[1:])
for _ in range(N - 1):
    lst = input().split()
    s2 = set(lst[1:])
    s1 = s1 & s2
    
print(len(s1))

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

c = []
for i in b:
    for j in i:
        c.append(j)
cco = 0

for k in b[0]:
    if c.count(k) == a[0]:
        cco = cco + 1

print(cco)

Solution (Python):

N, M = map(int,input().split())
for n in range(N):
    L = list(map(int,input().split())) 
    if n == 0:
        s = set(L[1:])
    else:
        s = s&set(L[1:])
print (len(s))

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

m_lis= [0 for i in range(M+1)]
for i in range(N):
    for j in range(a[i][0]):
        m_lis[a[i][j+1]]+=1
        
        

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

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

for i in range(1,M+1):
    isLike = True
    for j in k:
        if not i in j[1:]:
            isLike = False
    if isLike:
        ans += 1

print(ans)

Solution (Python):

n, k = map(int, input().split())
t = [[int(x) for x in input().split()] for _ in range(n)]

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

Solution (Python):
n, m = input().split()
fav_foods = {}
for i in range(0, int(n)):
    foods = input().split()
    for food in foods[1:]:
        if not food in fav_foods:
            fav_foods[food] = 1
        else:
            fav_foods[food] += 1

res = 0
for food in fav_foods.keys():
    if fav_foods[food] == int(n):
        res += 1
print(res)

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

likes = [0 for x in range(M)]

for n in range(N):
    s = [int(x) for x in input().split()]
    K = s[0]
    for k in range(K):
        likes[s[1+k] - 1] += 1

print(likes.count(N))

Solution (Python):
import collections
N,M = map(int,input().split())
listed = []
ans = 0
for i in range(N):
    listed.extend(list(map(int,input().split()))[1:])
a = collections.Counter(listed)
for num,count in a.items():
    if count == N:
        ans+=1
print(ans)

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

counter = [0] * M

for i in range(N):
    L = A[i]
    for l in L:
        counter[l - 1] += 1

indices = [i for i, c in enumerate(counter) if c == N]

print(len(indices))

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

lv = []
for i in range(N):
    a = [int(i) for i in input().split()] 
    lv.append(set(a[1:]))

res = lv[0]
for i in lv:
    res = res & i

print(len(res))

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

for i in range(n):
    k, *S = [int(i) for i in input().split()]
    ans &= set(S)

print(len(ans))

Solution (Python):
def main():
    n, m = [int(x) for x in input().rstrip("\n").split(" ")]

    from collections import defaultdict
    favorites = defaultdict(int)

    for i in range(n):
        k , *foods = [int(x) for x in input().rstrip("\n").split(" ")]
        for food in foods:
            favorites[food] += 1

    count = 0
    for food in range(1, m+1):
        if favorites[food] == n:
            count += 1
    print(count)

if __name__ == '__main__':
	main()

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    dic = {}
    for m in range(1, M + 1):
        dic[m] = 0

    for i in range(N):
        input_raw = read_func().strip().split()
        K = int(input_raw[0])
        for j in range(K):
            dic[int(input_raw[j + 1])] += 1

    count = 0
    for m in dic:
        if dic[m] == N:
            count += 1
    print count


if __name__ == '__main__':
    main()

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

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

print(len(all_like))

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

cnt = [0]*m
for i in range(n):
    l = list(map(int,input().split()))
    l = l[1:]
    for k in l:
        cnt[k-1] += 1
print(len([item for item in cnt if item>=n]))

Solution (Python):
def main():
    
    N,M = list(map(int,input().split()))
    ary = [[0 for _ in range(M)] for _ in range(N)]
    for i in range(N):
        a = list(map(int,input().split()))
        for j,elem in enumerate(a):
            if j == 0:
                continue
            ary[i][elem-1] = 1
    cnt = 0
    for j in range(M):
        ok = True
        for i in range(N):
            ok = ok and (ary[i][j]==1)
        if ok:
            cnt += 1
    print(cnt)
    return 0

if __name__=='__main__':
    main()

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

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

dic = {}
for i in range(N):
    L = list(map(int, input().split()))
    L.pop(0)
    for i in L:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1

ans = 0
for i, j in dic.items():
    if j == N:
       ans += 1

print(ans)

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

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

for i in range(N):
    K = arr[i][0]
    for j in range(1,K+1):
        count_arr[arr[i][j]-1] += 1

count = 0
for i in count_arr:
    if i == N:
        count += 1

print(count)

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

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

print(len(temp))

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

Solution (Python):
n,m=map(int,input().split())
x = [0 for _ in range(m)]
for _ in range(n):
  t = input().split()
  k = t[0]
  a = list(map(int,t[1:]))
  for aa in a:
    aa -= 1
    x[aa] += 1
x = list(filter(lambda s: 1 if s == n else 0, x))
print(len(x))

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

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

like = [ 0 for x in range(M+1)]
for ka in KA:
    a = ka[1:]
    for aa in a:
        like[aa] += 1


cnt = 0
for l in like:
    if l == N:
        cnt += 1
print(cnt)

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

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

ans=0

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

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


main()

Solution (Python):



def main():
    n, m = map(int, input().split())
    ans = [0 for _ in range(30)]

    for i in range(n):
        ka = list(map(int, input().split()))

        for j in ka[1:]:
            ans[j - 1] += 1

    result = 0

    for a in ans:
        if a == n:
            result += 1

    print(result)


if __name__ == '__main__':
    main()

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

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

for i in range(1,m+1):
    flag = True
    for a in alist:
        if i in a:
            continue
        else:
            flag = False
            break
    if flag:
        ans +=1
        
print(ans)

Solution (Python):

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

s=dict()
for i in range(N):
    a=list(map(int,input().split()))
    for i in range(1,len(a)):
        if(a[i] not in s):
            s.update({a[i]:1})
        else:
            s[a[i]]+=1
ans=0
for i in range(1,len(s)+1):
    try:
        if(s[i]==N):
            ans+=1
    except:
        pass
if(N==1):
    print(a[0])
else:
    print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N, M = il()
    food = {i: 0 for i in range(1, M + 1)}
    for n in range(N):
        i = il()
        for x in i[1:]:
            food[x] += 1
    ans = 0
    for f in food:
        if food[f] == N:
            ans += 1
    return ans


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

Solution (Python):
p = input().split()
n = int(p[0])
m = int(p[1])
k = []
for i in range(n):
    l = input().split()
    for j in range(int(l[0])):
        k.append(l[j+1])
c = 0
for i in range(m):
    s = 0
    for j in k:
        if (i+1) == int(j):
            s += 1
    if s == n:
        c += 1
print(c)

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

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

Solution (Python):
from functools import reduce
N, M = list(map(int, input().split()))
K = [set([int(a) for a in input().split()[1:]]) for _ in range(N)]
print(len(reduce(lambda x, y: x.intersection(y), K)))

Solution (Python):
N,M=[int(x) for x in input().split()]
result=list(range(1,M+1))
for i in range(N):
    I=input().split()
    K=int(I[0])
    As=[int(x) for x in I[1:]]
    result=list(set(As)&set(result))
print(len(result))

Solution (Python):
N,M = map(int,input().split(" "))
list = [0] * (M+1)


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

C = 0
for i in range(len(list)):
    if list[i] == N:
        C += 1
print(C)

Solution (Python):

N,M=map(int,input().split())
lr=list(map(int,input().split()))[1:]
s = set(lr)

for i in range(N-1):
    l = list(map(int, input().split()))[1:]
    s = s&set(l)

print(len(s))

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

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

Solution (Python):
[n,m] = [int(i) for i in input().split()]
ka = []
for i in range(n):
    ka.append([int(j) for j in input().split()])
dic = {}

for i in range(n):
    for j in range(1,len(ka[i])):
        if ka[i][j] not in dic.keys():
            dic[ka[i][j]] = 1
        else:
            dic[ka[i][j]] += 1
count = 0
for i in range(1,m+1):
    if i in dic.keys() and dic[i] == n:
        count += 1

print(count)

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

ans = set()
for i in range(n):
  c=list(map(int, input().split()))
  c.pop(0)
  if i ==0:
    ans = set(c)
  else:
    ans = ans & set(c)
print(len(ans))

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

a = [int(i) for i in input().split()][1:]
s = set(a)

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

print(len(s))

Solution (Python):

N,M = map(int,(input().split()))
A = [list(map(int,input().split()[1:])) for i in range(N)]
numFav = [0]*M
for line in A:
    for a in line:
        numFav[a-1] = numFav[a-1] + 1
print(numFav.count(N))

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

for i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    aa = set(ka[1:])
    if temp is None:
        temp = aa
    else:
        temp.intersection_update(aa)

if temp is None:
    print(0)
else:
    print(len(temp))

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

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

print(ans)

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

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

for _ in range(N):
    K1, *A = [int(a) for a in input().split()]
    for i in range(M):
        if i+1 not in A:
            X[i] = 0
        
print(sum(X))

Solution (Python):
def solve(N, M, KAs):
    ans = 0
    for m in range(1, M+1):
        if all(m in KAs[n][1:] for n in range(N)):
            ans += 1
    return ans


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    KAs = list(list(map(int, input().split(" "))) for _ in range(N))
    print(solve(N, M, KAs))

Solution (Python):
N, M = [int(v) for v in input().split()]
line = [int(v) for v in input().split()]
foods = set(line[1:])

for i in range(1, N):
    line = [int(v) for v in input().split()]
    foods = foods & set(line[1:])

print(len(foods))

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

print(ans)

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

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

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

print(count)