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())
for i in range(n):
    v = map(int, input().split())
    T = set(list(v)[1:])
    if i == 0:
        S = T
    else:
        S &= T
print(len(S))

Solution (Python):
import numpy as np
N, M = map(int,input().split())
kinds = np.zeros(M)
for _ in range(N):
    inputs = input().split()
    K = inputs[0]
    A = inputs[1:]
    for a in A:
        kinds[int(a)-1] += 1
N = len(kinds[np.where(kinds==N)])
print(N)

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

S = set()

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

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

cnt = np.array([0 for x in range(m + 1)])

for i in range(n):
    a = list(map(int, input().split()))[1:]
    cnt[a] += 1
print(np.sum(cnt >= n))

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

Solution (Python):
import numpy as np
N,M=map(int,input().split())
A=np.zeros((N+1,M+1))
A[0]=np.ones(M+1)
for i in range(1,N+1):
    B=list(map(int,input().split()))
    for m in range(1,B[0]+1):
        A[i][B[m]]=A[i-1][B[m]]
a=sum(A[N])
print(int(a))

Solution (Python):
n,m = map(int, input().split())
a = [[False for _ in range(m)] for _ in range(n)]
for i in range(n):
  l = list(map(int, input().split()))
  for j in l[1:]:
    a[i-1][j-1] = True

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

Solution (Python):

data = input().split()
n = int(data[0]) 
m = int(data[1]) 
ans = 0


j = 1 
i = 1 
c = [0] * (m + 1)
    

while i <= n:
    tmp = [int(s) for s in input().split()]
    td = tmp[1:] 
    tn = tmp[0]  
    
    
    while j <= m: 
        
        if j in td: 
            j = int(j) 
            
            c[j] += 1 
        j = int(j) 
        j += 1
    j = 1    
    i += 1 



for x in c:
    if x == n:
        ans += 1



print(ans)

Solution (Python):

data = input().split()
n = int(data[0]) 
m = int(data[1]) 
ans = 0


j = 1 
i = 1 
c = [0] * (m  *2)
    

while i <= n:
    tmp = [int(s) for s in input().split()]
    td = tmp[1:] 
    tn = tmp[0]  
    
    
    while j <= m: 
        
        if j in td: 
            j = int(j) 
            
            c[j] += 1 
        j = int(j) 
        j += 1
    j = 1    
    i += 1 



for x in c:
    if x == n:
        ans += 1



print(ans)

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

Solution (Python):
print(len(set.intersection(*[set(s.split()[1:])for s in open(0).readlines()[1:]])))

Solution (Python):
if __name__ == "__main__":
    n, m = [int(x) for x in input().strip().split(' ')]
    hyp = set()
    for i in range(n):
        line = [int(x) for x in input().strip().split(' ')]
        if i == 0:
            hyp = set(line[1:])
            continue
        hyp = hyp.intersection(set(line[1:]))
    print(len(hyp))

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

Solution (Python):
people, meals = map(int, input().split(" "))
count = {i:0 for i in range(1, meals+1)}

for person in range(people):
    meals = input().split(" ")
    number_liked = int(meals[0])
    meals_liked = [int(m) for m in meals[1:]]
    for i in meals_liked:
        count[i] += 1
ans = 0
for k, v in count.items():
    if people==v:
        ans += 1
print(ans)

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

for i in range(N):
    A = list(map(int,input().split()))
    for j in A[1:]:
        K[j-1]+=1
for i in K:
    if i==N:
        a+=1
print(a)

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

a = [0 for _ in range(M)]

for _ in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    for i in range(len(A)):
        a[A[i]-1] += 1

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

Solution (Python):
def solve(str_in_arr):
    """
    Calculate common favorite foods number of people

    Paramaters
    ----------
    str_in_arr : list of str
        list of string from standard input
        A first element of the list is number of favorite foods.

    Returns
    -------
    num_common_favorite_food : int
        common favorite foods number
    """
    _num_person, _num_food = str_in_arr[0].split()
    num_person, num_food = int(_num_person), int(_num_food)
    fav_foods_list = str_in_arr[1::]

    favorite_foods = [0] * int(num_food)

    for fav_foods in fav_foods_list:
        foods = fav_foods.split()[1::]
        for food in foods:
            idx_food = int(food) - 1
            favorite_foods[idx_food] += 1

    num_common_favorite_food = 0
    for num_person_per_food in favorite_foods:
        if num_person_per_food == num_person:
            num_common_favorite_food += 1

    return num_common_favorite_food


def main():
    num_person_and_food = input()
    _num_person, _ = num_person_and_food.split()
    num_person = int(_num_person)

    std_in = [num_person_and_food if idx == 0 else input() for idx in range(num_person+1)]
    print(solve(std_in))


if __name__ == "__main__":
    main()

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

for i in range(m + 1):
    menu_count.append(0)

ans = 0

for i in range(n):
    l.append(list(map(int,input().split())))

for i in range(n):
    for j in range(1, l[i][0] + 1):
        for k in range(1, m + 1):
            if l[i][j] == k:           
                
                menu_count[k] += 1


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





print(ans)

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

Solution (Python):
N, M = map(int, input().split())
likes = [0] * M
for _ in range(N):
    temp = list(map(int, input().split()))
    for i in range(1, len(temp)):
        likes[temp[i] - 1] += 1
print(len([e for e in likes if e == N]))

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

tmp=[0]*(M+1)
for i in range(N):
	for j in range(1,KA[i][0]+1):
		tmp[KA[i][j]]+=1

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

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

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

for i in range(n):
    popped_item1=listA[i].pop(0)

listB=[]
for i in listA:
    for j in i:
        listB.append(j)

cnt=0
for i in range(m+1):
    if listB.count(i)==n:
        cnt+=1
print(cnt)

Solution (Python):
N, M = (int(i) for i in input().split())
hoge = {i + 1 for i  in range(M)}

for i in range(N):
    likes = set()
    on = input().split()
    on.pop(0)
    likes = {int(j) for j in on}
    hoge &= likes


c = len(hoge)

print(c)

Solution (Python):
N,M=map(int,input().split(" "))
lists=[]
count=0
for a in range(N):
    lists+=input().split(" ")[1:]
for a in range(1,M+1):
    if(lists.count(str(a))==N):
        count+=1
print(count)

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

li_m = list()

for i in range(n):
    li_m = li_m + input().split()[1:]

counter = 0
for m in set(li_m):
    if li_m.count(m) == n:
        counter += 1
print(counter)

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

s=[]
for t in e:
  b_list=0
  for x in t[1:]:
    b_list = b_list | pow(2,x-1)
  s.append(b_list)
result=pow(2,30)-1
for i in s:
   result = result & i
cnt=0
for i in range(30):
  if result & pow(2,i):
    cnt+=1
print(cnt)

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

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

print(len(a[n-1]))

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

Solution (Python):
import sys
num = sys.stdin.readline().split()
d = {}
for line in sys.stdin.readlines():
  n = line.split()
  n.pop(0)
  for s in n:
    if s in d :
      d[s] = d[s]+1
    else :
      d[s] = 1
keys = [k for k, v in d.items() if v == int(num[0])]
print(len(keys))

Solution (Python):
n, m = map(int,input().split())
k = []
for i in range(n):
    K = list(map(int,input().split()))
    k.append(K)
ans = 0
for q in range(1,m+5):
    Z = 0
    for i in range(n):
        a = []
        b = []
        a.append(k[i])
        b = a[0]
        for l in range(1, b[0]+1):
            if b[l] == q:
                Z += 1
    if Z == n:
        ans += 1
print(ans)

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
    for K_n_list_num in K_n_list:
        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]

print(len(prefer_dish))

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]


    for K_n_list_num in K_n_list:
        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]




print(len(prefer_dish))

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]


    for K_n_list_num in K_n_list:
        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))

for dish_kind_num in dish_kind:
    if all_dish.count(dish_kind_num) == N:
        prefer_dish.append(dish_kind_num)

print(len(prefer_dish))

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

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
    for K_n_list_num in K_n_list:
        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
for dish_kind_num in dish_kind:
    if all_dish.count(dish_kind_num) == N:
        prefer_dish.append(dish_kind_num)

print(len(prefer_dish))

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

Solution (Python):
from sys import stdin

n, m = (int(i) for i in input().split())

l = [int(x) for x in stdin.readline().rstrip().split()]
l.pop(0)
for i in range(n-1):
    l2 = [int(x) for x in stdin.readline().rstrip().split()]
    l2.pop(0)
    l = list(set(l)&set(l2))

print(len(l))

Solution (Python):


import sys
import math

def parse_input(lines_as_string = None):

    lines = []
    if lines_as_string is None:
        for line in sys.stdin:
            lines.append(line)
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    
    nm = lines[0].split(" ")
    n = int(nm[0])
    m = int(nm[1])

    rows = []
    for i in range(1, n+1):
        rows.append([int(e) for e in lines[i].split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):

            r = rows[i]

            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return len(result)

def main():

    print("%d" % solve(*parse_input()))

if __name__ == '__main__':

    main()

Solution (Python):


import sys

def parse_input(lines_as_string = None):

    lines = []
    if lines_as_string is None:
        for line in sys.stdin:
            lines.append(line)
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    
    nm = lines[0].split(" ")
    n = int(nm[0])
    m = int(nm[1])

    rows = []
    for i in range(1, n+1):
        rows.append([int(e) for e in lines[i].split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):

            r = rows[i]

            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return len(result)

def main():

    n, m, rows = parse_input()
    print("%d" % solve(n, m, rows))

if __name__ == '__main__':

    main()

Solution (Python):
x1 = input().split()
N = int(x1[0])
M = int(x1[1])
S = []
A = []
K = []
F = []
for i in range(M):
    S.append(0)
for i in range(N):
    K.append(0)
for i in range(N):
    A.append(input().split())
    K[i] = int(A[i][0])
    for j in range(K[i]):
        F.append(int(A[i][j+1]))
    for j in F:
        S[j - 1] += 1
    F = []
ans = 0
for i in range(M):
    if S[i] == N:
        ans += 1
print(ans)

Solution (Python):


def parse_input():

    
    nm = input().split(" ")
    n = int(nm[0])
    m = int(nm[1])

    rows = []
    for i in range(0, n):
        rows.append([int(e) for e in input().split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):

            r = rows[i]

            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return str(len(result))

def main():

    n, m, rows = parse_input()
    print(solve(n, m, rows))

if __name__ == '__main__':

    main()

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

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

count_list = [0] * 31 
for i in range(n):
    for j in range(1, len(kind_list[i])):
        count_list[kind_list[i][j]] = count_list[kind_list[i][j]] + 1

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

print(count)

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

print(M.count(n))

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

Solution (Python):
import functools
N, M = (int(x) for x in input().split())
KA_arr = []
for i in range(N):
    KA_arr.append([int(x) for x in input().split()])

M_arr = [1]*M
for KA in KA_arr:
    for i in range(M):
        if not i+1 in KA[1:]:
            M_arr[i] = 0

ans = functools.reduce(lambda x,y:x+y, M_arr, 0)
print(ans)

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

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

like = [0] * M

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

print(len([l for l in like if l == N]))

Solution (Python):
import sys
import pprint

pp = pprint.PrettyPrinter(indent=4)

def main():
    """ Code implementation """
    N, M = map(int, input().split())
    all_love = [True] * M
    for n in range(N):
        arr = list(map(int, input().split()))
        K, A = arr[0], arr[1:]
        this_love = [False] * M
        for k in range(K):
            a = int(A[k])
            this_love[a-1] = True
        for m in range(M):
            if all_love[m] and not this_love[m]:
                all_love[m] = False

    sum_love = 0
    for m in range(M):
        if all_love[m]:
            sum_love += 1
    print(sum_love)

if __name__ == '__main__':
    main()

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

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

for i in range(n):
    sel = [int(i)-1 for i in input().split(" ")][1:]
    for s in sel:
        pre_res[s] += 1

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

print(res)

Solution (Python):




"""








"""
from collections import Counter

def i():
    n_people = int(input().split()[0])
    likes = []

    for i in range(n_people):
        likes.extend(input().split()[1:])

    return n_people, [int(l) for l in likes]

def s(n_people, likes):
    re = 0
    cn = Counter(likes)
    food = cn.keys()
    for f in food:
        if cn[f] == n_people:
            re += 1
    return re

if __name__ == '__main__':
	print(s(*i()))

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

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

ans = 0
for k in cnt:
    if cnt[k] == N:
        ans += 1
print(ans)

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

correction = []
for j in range(n):
   correction += [input().split()]


list_and = correction[0][1::]
for j in range(1, n):
   list_and = set(list_and) & set(correction[j][1::])
   list_and = list(list_and)

print(len(list_and))

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

a = []

for i in range(N):
  b = list(map(int,input().split()))
  a.append(b)
           
c = [0]*M

for i in range(N):
	for j in range(M):
		c[j] += a[i][1:].count(j+1) 

ans = 0

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

print(ans)

Solution (Python):
n,m = [int(x) for x in input().split()]
s = set()
for i in range(n):
  _, *n = [int(x) for x in input().split()]
  if i == 0:
    s = set(n)
  else:
    s &= set(n)
print(len(s))

Solution (Python):
import numpy as np

i = [int(each) for each in input().split()]

n = i[0]
m = i[1]

l2 = np.zeros(m)

for i in range(n):
    for j, each in enumerate([int(each) - 1 for each in input().split()]):
        if j != 0:
            l2[each] += 1
    

count = 0
for each in l2:
    if each == n:
        count += 1
print(count)

Solution (Python):
import sys

v = []
for line in sys.stdin:
    v.append([int(l) for l in line.split()])

n = v[0][0]
m = v[0][1]

a = None
for line in v[1:]:
  if a == None:
    a = line[1:]
  else:
    c = []
    for b in a:
      if b in line[1:]:
        c.append(b)
    a = c
print(len(a))

Solution (Python):
N,M = map(int,input().split())
List = []
like_dic = {}
like = 0
for i in range(N):
    List.append(input().split())
for i in range(N):
    for j in range(1,len(List[i])):
        if List[i][j] in like_dic:
            like_dic[List[i][j]] += 1
        else:
            like_dic[List[i][j]] = 1
for k in like_dic.keys():
    if like_dic[k] == N:
        like += 1
print(like)

Solution (Python):




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


cnt = [0] * m
for i in range(n):
    a = list(map(int,input().split()))
    
    for j in range(1,a[0]+1):
        cnt[a[j]-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())
L=[0 for j in range(30)]
for i in range(n):
  l=list(map(int,input().split()))
  l.pop(0)
  for k in range(1,31):
    if k in l:
      L[k-1]+=1
ct=0
for p in range(len(L)):
  if L[p]==n:ct+=1
print(ct)

Solution (Python):
n,m=map(int,input().split())
ka=[[int(i) for i in input().split()] for j in range(n)]
num=[0 for i in range(m+1)]
count=0
for i in range(n):
    for j in range(1,ka[i][0]+1):
        num[ka[i][j]]+=1

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

print(count)

Solution (Python):
N,M =[int(i)for i in input().split()]
l =[0]*M
for i in range(N):
    for j,st in enumerate(input().split()):
        if j != 0:
            st =int(st)-1
            l[st] += 1
ans =l.count(N)
print(ans)

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

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





while True:
    if len(full_ent) == 1:
        out_flag = len(full_ent[0])
        break
    full_ent[1] = list(set(full_ent[0]) & set(full_ent[1]))
    full_ent.pop(0)

def out(out_flag):
    print(out_flag)

out(out_flag)

Solution (Python):


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

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

    if i ==0:
        all_and = List[0]
    else:
        all_and = set(all_and) & set(List[i])
        all_and = list(all_and)


print(len(all_and))

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

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

if N == 1:
    print(len(A[0]))
    quit()
else:
    res = list(set(A[0]) & set(A[1]))
    for a, v in enumerate(A):
        res = list(set(res) & set(v))
    print(len(res))

Solution (Python):
people, foods = [int(x) for x in input().split()]
favors = []
for person in range(people):
  favor = [int(x) for x in input().split()]
  favors.append(favor[1:])
  
test_result = 0
if len(favors) == 1:
  test_result = len(favors[0])
else:
  all_taste = [x for favor in favors for x in favor ]
  
  for food in set(all_taste):
    if all_taste.count(food) == people:
      test_result += 1

print(test_result)

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

for food in list(range(1,M+1)):
    for row in range(N):
        if str(food) not in A[row]:
            break
    else:
        c += 1
        continue
    
print(c)

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

Solution (Python):
if __name__ ==  "__main__":
    food_data = []
    n, m = map(int, input().split())
    for i in range(n):
        food_row = list(map(int, input().split()))
        food_row.pop(0)
        food_data.append(food_row)

    result = 0
    first_food_row = food_data[0]
    rest_food_rows = food_data[1:]

    for food in first_food_row:
        flag = False
        for food_row in rest_food_rows:
            if not food in food_row:
                flag = True
                break
            
        if flag:
            continue

        result += 1 

    print(result)

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

foods = list()
for _ in range(n):
    foods.append([int(x) for x in input().split()])

foods.sort(reverse = True)
foods = [f[1:] for f in foods]

count = 0
for f in foods[0]:
    if all(map(lambda l: f in l, foods[1:])):
        count += 1

print(count)

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

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

c = 0
for i in range(1, m+1):
    g = True
    for j in range(n):
        if i not in l[j][0:]:
            g = False
    if g:
        c = c + 1

print(c)

Solution (Python):
n, m = map(int, raw_input().split())
dic = {}
for i in range(n):
  l = map(int, raw_input().split())[1:]
  for j in l:
    if j in dic:
      dic[j] += 1
    else:
      dic[j] = 1
ans = 0
for i in dic:
  if dic[i] == n:
    ans += 1
print ans

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

for _ in range(N):
  hypo.append([int(s) for s in input().split(' ')][1:])

like_counts = [0] * M
for h in hypo:
  h_ = list(set(h))
  for i in h_:
    like_counts[i - 1] += 1

counts = 0
for i in like_counts:
  if i == N:
    counts += 1
print(counts)

Solution (Python):
N,M = map(int, input().split())
like=[]
cnt=0
for i in range(N):
	like.append(list(map(int, input().split()))[1:])
for j in range(1,M+1):
	if all ([j in x for x in like]):
		cnt += 1
print(cnt)

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

listA = [[int(i) for i in input().split()] for i in range(n)] 

ans = 0

for a in range(1, m+1):
    ok = True
    for i in range(n):
        if a not in listA[i][1:]:
            ok = False
    if ok:
        ans += 1

print(ans)

Solution (Python):
from itertools import chain

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


for low in data:
	del low[0]

data = list(chain.from_iterable(data))

counter = 0

for i in range(1, m+1):
	if data.count(i) == n:
		counter += 1

print(counter)

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

Solution (Python):
from collections import Counter
def foods():
    n,m=map(int,input().split())
    ka=[[int(i) for i in input().split()] for i in range(n)]
    food=[i for i in range(1,m+1)]
    ans=[]
    for i in ka:
        hito=i[1:]
        ans+=[x for x,y in Counter(hito+food).items() if y>1]
    ansa=[x for x,y in Counter(ans).items() if y==n]
    return ansa

print(len(foods()))

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

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

print(len(Food_fav))

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

s = set()
A = [int(x) for x in input().split()]
s = set(A[1::])
for _ in range(N - 1):
    A = [int(x) for x in input().split()]
    s &= set(A[1::])


print(len(s))

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

    for j in range(1,b[0]+1):
        a[b[j]] += 1
t = 0
for i in range(len(a)):
    if a[i] == n:
        t += 1

print(t)

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

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

for i in range(N):
    a,*b = map(int,input().split())
    M_kinds &= set(b)

print(len(M_kinds))

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


seki = a[0]
for i in range(N-1):
    seki = seki & a[i+1]
    
print(len(seki))

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

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

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

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

c = []
d = []
for i in range(n):
    a = [int(x) for x in input().split(" ")]
    if i == 0:
        c = a[- a[0]:]
    else:
        b = a[- a[0]:]
        for ce in c:
            if ce in b:
                 d.append(ce)
        c = d
        d = []

print(len(c))

Solution (Python):
N_M = list(map(int,input().split()))
N = N_M[0]
M = N_M[1]
ans = 0

list_sum = [0] * M

for i in range(N):
    tmp = list(map(int,input().split()))
    for j in tmp[1:]:
        list_sum[j - 1] +=1
        
for i in list_sum:
    if i == N:
        ans +=1
        
print(ans)

Solution (Python):
N,M=list(map(int,input().split(" ")))
bucket=[0 for _ in range(M+1)]
for i in range(N):
  r=list(map(int,input().split(" ")))
  for j in r[1:]:
    bucket[j]+=1
print(sum([i==N for i in bucket]))

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

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

for i in range(n):
    l = list(map(int, input().split()))
    del l[0]
    li += l
    
for i in range(1, m+1):
    if li.count(i) == n:
        box.append(i)

print(len(box))

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


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

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

Solution (Python):
import sys
n, m = map(int, sys.stdin.readline().split())

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

for i in range(n):
    x &= set(list(map(int, sys.stdin.readline().split()))[1:])

print(len(x))

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

listA = [list(map(int, input().split())) for j in range(n)]

ans = 0


for a in range(1, m+1):
    ok = True
    for i in range(n):
        if a not in listA[i][1:]:
            ok = False
    if ok:
        ans += 1



print(ans)

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

Solution (Python):
n, m = map(int, input().split())
arr = [list(map(int, input().split()))[1:] for i in range(n)]
cnt = [0 for i in range(m)]
for v in arr:
    for vi in v:
        cnt[vi - 1] += 1

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

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

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

print(len(arr))