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())
a = [list(map(int, input().split())) for i in range(n)]
result = [0 for i in range(m)]
for mindex in range(0,m):
    for nindex in range(0,n):
        for kindex in range(1,a[nindex][0]+1):
            if a[nindex][kindex] == mindex+1:
                result[mindex]+=1
            else:
                pass
                
 
print(result.count(n))

Solution (Python):
N = input().split()[0]
like = set(input().split()[1:])
for i in range(int(N) - 1):
    like = like & set(input().split()[1:])
print(len(like))

Solution (Python):
n, m = map(int, input().split())
k = list(map(int, input().split()))
del k[0]
ans = set(k)

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

    x = set(x)
    ans = ans & x

ans = list(ans)

print(len(ans))

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

Solution (Python):
n, m = map(int, input().split())
k = list(map(int, input().split()))
del k[0]
ans = set(k)

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

    x = set(x)
    ans = ans & x

ans = list(ans)

print(len(ans))

Solution (Python):
import numpy as np

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

A=np.zeros((N,M))

for i in range(N):
    AA=list(map(int,input().split()))
    AA.pop(0)

    for j in AA:
        A[i][j-1]=1

for i in range(N-1):
    A[0]=A[0]*A[i+1]

print(np.sum(A[0]==1))

Solution (Python):
num, food_num = map(int, input().rstrip().split(" "))

food_list = [i + 1 for i in range(food_num)]

for i in range(num):
    input_line = input().rstrip().split(" ")
    input_line.pop(0)
    favorite_food = [int(j) for j in input_line]
    food_list = list(set(favorite_food) & set(food_list))

print(len(food_list))

Solution (Python):
from itertools import chain
from collections import Counter

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

print(sum(c==N for c in Counter(chain(*A)).values()))

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

Solution (Python):
a,b=map(int, input().split())

list2=[]
for i in range(a):
    c=list(map(int, input().split(" ")))
    del c[0]
    list2.append(c)
    
res= set(list2[0])
for i in range(1, a):
    res=res & set(list2[i])

r= len(res)
print(r)

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

K.sort(key=lambda x:x[0])

tmp=set(K[0][1:])
for A in K[1:]:
  tmp=tmp&set(A[1:])
  
print(len(tmp))

Solution (Python):

"""
Created on Sat Feb 16 21:12:07 2019

@author: yff20
"""

l1 = input().split()

ln = [0] * (int(l1[1]))

for num in range(0, int(l1[0])):
   l2 = input().split()
   for index in range(1, len(l2)):
       ln[int(l2[int(index)])-1] += 1
    
count = 0

for i in ln:
    if(i==int(l1[0])):
        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()))[1:])
X=A[0]
for i in range(N-1):
    X=set(X) & set(A[i+1])
print(len(X))

Solution (Python):
print((lambda p: sum([1 if sum([sum([1 if p[2][j][k+1]-1==i else 0 for k in range(p[2][j][0])]) for j in range(p[0])])==p[0] else 0 for i in range(p[1])]))((lambda a: [a[0],a[1],[list(map(int,input().split())) for i in range(a[0])]])(list(map(int,input().split())))))

Solution (Python):
N, M = (int(x) for x in input().split())
KA = [[int(x) for x in l] for l in [input().split() for i in range(N)]]
[x.pop(0) for x in KA]

x = []
for s in KA:
  x.extend(s)

c = 0
for i in range(1, M + 1):
  
  c = c + (1 if x.count(i) == N else 0)
print(c)

Solution (Python):


import numpy


def main():
  n, m = list(map(int, input().split()))
  a = numpy.ones(m)

  for _ in range(n):
    b = numpy.zeros(m)
    b[list(map(lambda x: int(x) - 1, input().split()))[1:]] = 1
    a *= b

  print(int(numpy.sum(a)), flush=True)


if __name__ == '__main__':
  main()

Solution (Python):
N,M = map(int, input().split())
el = {}
for i in range(N):
    P = list(map(int, input().split()))
    K = P.pop(0)
    if i == 0: el = set(P)
    el = el & set(P)
print(len(el))

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

I = [True]*(M)

for j in range(1,M+1):
    for ki in range(N):
        if not (j in A[ki]):
            I[j-1] = False

print(I.count(True))

Solution (Python):
n,m=map(int,input().split())
l=[]
for i in range(n):
    a=list(map(str,input().split()))
    v=int(a[0])
    a.pop(0)
    for i in range(v):
        l.append(a[i])
s=[]
i=0
while i<m:
    i+=1
    i=str(i)
    s.append(l.count(i))
    i=int(i)
print(s.count(n))

Solution (Python):
listA=[] 
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
x,y = map(int, listA[0])
l1 = listA[1][1:]
la = []
for a in l1:
  if x == 1:
    la.extend(l1)
    break
  b = True
  for lr in listA[2:]:
    if lr[1:].count(a) == 0:
      b=False
      break
  if b:
    la.append(a)


print(len(la))

Solution (Python):
import numpy as np
n,m = map(int,input().split())
ans = np.ones(m+1)
ans[0] = 0
for i in range(n):
    a = list(map(int,input().split()))
    a.pop(0)
    for i in range(1,m+1):
        if i in a:
            continue
        else:
            ans[i] = 0
print(int(np.sum(ans)))

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

s=set()
for i in range(m):
    s.add(i+1)


for i in range(n):
    a= [int(j) for j in input().split()]
    a.pop(0)
    a=set(a)
    s=s & a

print(len(s))

Solution (Python):
n, m = [int(x) for x in input().split()]
food_list = [0 for x in range(m)]
 
for i in range(n):
  s = [int(x) for x in input().split()]
  k = s[0]
  e = s[1:]
  for j in range(k):
    food_list[e[j]-1] += 1

ans = 0

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

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

product = set(i for i in range(1, m+1))

for i in range(0, n):
	As = set(map(int, input().split()[1:]))
	product = product.intersection(As)
	
print(len(product))

Solution (Python):
n, m = map(int, input().split())
array = []
for i in range(n):
    array.append([int(k) for k in input().split()])
result = {}
for arr in array:
    for i, k in enumerate(arr):
        if i == 0:
            continue
        if k not in result:
            result[k] = 0
        result[k] += 1
res = 0
for i in result.items():
    if i[1] == n:
        res += 1
print(res)

Solution (Python):
from sys import stdin


def count_samples_of_like_same_food(n, m, samples_and_like_foods):
    
    like_foods_num_dict = {}
    for samples_like_foods in samples_and_like_foods:
        
        sample = samples_like_foods[0]
        like_foods = samples_like_foods[1:]
        
        for like_food in like_foods:
            if like_food not in like_foods_num_dict:
                like_foods_num_dict[like_food] = 1
            else:
                like_foods_num_dict[like_food] += 1

    same_like_food_samples_count = 0
    for key, value in like_foods_num_dict.items():
        
        if value == n:
            same_like_food_samples_count += 1
        else:
            
            pass

    
    return same_like_food_samples_count


def main():
    input_line_list = stdin.readlines()
    input_line_list = [y.rstrip() for y in input_line_list]
    n, m = [int(z) for z in input_line_list[0].split()]
    samples_and_like_foods = [x.split() for x in input_line_list[1:]]
    
    
    
    
    
    print(count_samples_of_like_same_food(n, m, samples_and_like_foods))


if __name__ == '__main__':
    main()

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

ka=[]
ans=0

for i in range(n):
    atmp=list(input().split())
    ka.append(atmp)


like=ka[0][1::]

if n>1:
    for i in range(1,n):
        liketmp=ka[i][1::]
        for k in range(0,len(like)):
            if like[k] not in liketmp:
                     like[k]='0'

for j in range(len(like)):
    if like[j]!='0':
        ans+=1
print(ans)

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

Solution (Python):
n = 0
N, M = map(int, input().split())
A = []
for i in range(1,N+1):
    S = input().split()
    for j in range(len(S)):
        S[j] = int(S[j])
    A = A + S[1:]
    
for i in range(1, M+1): 
    cnt = A.count(i)
    if cnt == N:
        n += 1 
print("{}".format(n))

Solution (Python):
N, M = map(int,input().split())
num_li = [input().split() for n in range(N)]
num_li = sorted(num_li)





flag = False
count = 0

if len(num_li) ==  1:
  print(len(num_li[0][1:]))
  exit()

for i in range(1, int(num_li[0][0])+1):
  for j in range(1, len(num_li)):
    if num_li[0][i] in num_li[j][1:]:


      flag = True
    else:
      flag = False
      break
  if flag == True:
    count += 1
print(count)

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

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

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

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

likeList=[]
for i in range(n):
    ai=list(map(int,input().strip().split()))[1:]
    likeList.extend(ai)
like=0
for i in range(m):
    if likeList.count(i+1)==n:
        like+=1
print(like)

Solution (Python):
from sys import stdin
from collections import Counter

N, M = stdin.readline().rstrip().split()
N, M = int(N), int(M)

all_list = []

for i in range(N):
    a_list = stdin.readline().rstrip().split()
    a_list = a_list[1:]
    all_list += a_list

counter = Counter(all_list)
all_like_list = [value for key, value in counter.items() if value == N]
print(len(all_like_list))

Solution (Python):




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

print(o.count(n))

Solution (Python):
N,M=map(int,input().split())
data = [input().split() for i in range(N)] 
result=[]
for j in range(N):
    result=result+data[j][1:]
result=[int(s) for s in result]
ans=[x for x in result if result.count(x) == N]
print(int(len(ans)/N))

Solution (Python):
import collections
N,M = map(int, input().split())
p_list = []
for i in range(N):
  fli = list(map(int,input().split()))
  p_list.extend(fli[1:])
  c = collections.Counter(p_list)
  values, counts = zip(*c.most_common())


print(counts.count(N))

Solution (Python):
N, M = map(int, input().split())
List = list(range(1,M))
anser = []
def judge(N,M,List,anser):
  for i in range(N):
    L = list(map(int, input().split()))
    del L[0]
    if i==0:
      anser.extend(L)
    else:
      anser = list(set(L)&set(anser))
    
    
  print(len(anser))
judge(N,M,List,anser)

Solution (Python):
N,K=list(map(int, input().split()))
ans=[0]*31

K1=[]
cnt=0
for i in range(N):
	K1=list(map(int, input().split()))
	for i in range(K1[0]):
		ans[K1[i+1]]=ans[K1[i+1]]+1
	K1.clear()


for i in range(30):

	if ans[i+1]==N :
		cnt=cnt+1

print(cnt)

Solution (Python):
s = input()

n = int(s.split()[0])
m = int(s.split()[1])

inp = [input().split() for _ in range(n)]

count = 0
for i in range(1,m+1):
    flg = True
    for like in inp:
        if str(i) not in like[1:]:
            flg = False
            break
    if flg:
        count += 1

print(count)

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

count = 0
for i in range(K[0]):
    flag = True
    for j in range(N-1):
        if(inpu[0][i] not in inpu[j+1]):
            flag = False
    if (flag == True):
        count = count + 1
print(count)

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


for i in range(0,N):
    list[i].pop(0)

stock = []


for i in range(0,N):
    for j in range(0,len(list[i])):
        cnt = 0
        for k in range(0,N):
            if list[i][j] in list[k]:
                cnt += 1
        if cnt == N:
            stock.append(list[i][j])

if N == 1:
    stock = list[i]

print(len(set(stock)))

Solution (Python):
def generateBin(m, t):
    l = list(t)
    bin_num = 0
    for i in range( m):
        if l.count(i+1) == 1:
            bin_num += 1<< i
    return bin_num

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

ans = 0
for i in range( m):
    ans += 1 << i

bin_n =0
for i in range(n):
    k,*t = tuple(map(int,input().split()))
    bin_n = generateBin(m, t)
    ans = ans & bin_n

print('{:b}'.format(ans).count('1'))

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

a = []
k = []
for _ in range(n):
    ka = [int(i) for i in input().split()]
    k.append(ka[0])
    a.append(ka[1:])



mlist = [0] * m


for i in range(len(a)):
    for j in range(len(a[i])):
        mlist[a[i][j] - 1] += 1

counter = 0
for mlisti in mlist:
    if mlisti == n:
        counter += 1

print(counter)

Solution (Python):
import numpy as np

s=input().split(" ")
N=int(s[0])
lst=[]
for i in range(N):
    if i==0:
        lst=input().split(" ")[1:]
    else:
        lst = set(lst) & set(input().split(" ")[1:])
    
print(len(lst))

Solution (Python):


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

A = []
for k in range(N):
    Ai = [i for i in map(int, input().split())]
    _M = Ai.pop(0)
    A.append(Ai)

res = A[0]
for k in range(N - 1):
    res = list(set(res) & set(A[k + 1]))


print(len(res))

Solution (Python):


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

A = []

for n in range(N):
	A.append(list(map(int , input().split())))
	A[n].pop(0)


c = 0
Count = 0
for m in range(M):
	for n in range(N):
		if m+1 in A[n]:
			c += 1

	if c == N:
		Count += 1

	c = 0

print(Count)

Solution (Python):
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n):
        listB = []
        for k in range(1,listA[i][0]+1):
          listB.append(listA[i][k])
        if listA[0][j] not in listB:
          break
    else:
    	x += 1
print(x)

Solution (Python):
N,M = map(int, input().split(' '))
result = set(range(1,M+1)) 
for i in range(N):
  a = [int(j) for j in input().split(' ')]
  result =  result & set(a[1:])

print(len(result))

Solution (Python):
import sys
import io
import math

datalist = input().split()

i = 0
for i in range(int(datalist[0])):
    if i == 0:
        l_new = input().split()
        l_new.pop(0)
    if i != 0:
        l_input = input().split()
        l_input.pop(0)
        l_new = set(l_input) & set(l_new)

print(len(l_new))

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

dic = {}
for i in range(0,n):
    k = list(map(int,input().split()))
    for j in range(1,len(k)):
        if k[j] in dic:
            dic[k[j]] += 1
        else:
            dic[k[j]] = 1
        
res = 0
for key,value in dic.items():
    if value == n:
        res+=1
print(res)

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

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

num_list = list(set(num_list))

result = 0

for x in num_list:
    for a in k:
        f = False
        for b in a :
            if b == x:
                f = True
        if f != True:
            break
    if f :
        result += 1

print(result)

Solution (Python):

import sys



def solve(lines):
    N,M = map(int, lines.pop(0).split(' '))
    res = set(range(1,M+1))
    for i in range(N):
        a = list(map(int, lines.pop(0).split(' ')))
        a.pop(0)
        res = res & set(a)
    print(len(res))





lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Solution (Python):
N,M = map(int,input().split())
num =0
line_m=[]
line_s=[]
for k in range(M+1):
    line_m.append(0)
for i in range(N):
    line_s = list(map(int, input().split()))
    for n in range(int(line_s[0])):
        line_m[int(line_s[n+1])] = int(line_m[int(line_s[n+1])]) + 1

for s in range(M+1):
    if line_m[s] == N:
        num = num+1




print(num)

Solution (Python):
import numpy as np
import math

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

print(len(inter))

Solution (Python):
from sys import stdin

def main():
    N, M = map(int, input().split())
    A = [tuple(map(int, input().split())) for _ in [0] * N]

    ans = set(A[0][1:])
    for a in A:
        ans &= set(a[1:])
    print(len(ans))

input = lambda: stdin.readline()
main()

Solution (Python):
N,M = map(int,input().split())
a = []
love = 0
for i in range(N):
    a.append(list(map(int,input().split())))
for k in range(M):
    count = 0
    for i in range(N):
        if k+1 in a[i][1:]:
            count += 1
        else:
            break
    if count == N:
        love += 1
print(love)

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

num_dict = {}

if N == 0:
    print(0)
else:
    for i in range(N):
        data = list(map(int,input().split()))
        if len(data) > 1:        
            for j in range(len(data)-1):
                if data[j+1] in num_dict:
                    num_dict[data[j+1]] = num_dict[data[j+1]] + 1
                else:
                    num_dict[data[j+1]] = 1

if num_dict == {} or N not in num_dict.values():
    print(0)
else: 
    keys = [k for k, v in num_dict.items() if v == N]
    print(len(keys))

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

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

Solution (Python):
import numpy as np
N, M = input().split()
hito = []
for i in range(int(N)):
    hito.append(input().split())

for i in range(int(N)):
    hito[i] = list(map(int, hito[i]))

for i in range(int(N)):
    hito[i].pop(0)

hikaku = np.arange(1,int(M)+1)
for i in range(int(N)):
    hikaku = list(set(hikaku) & set(hito[i]))



print(len(hikaku))

Solution (Python):
from operator import add

n, m = map(int, input().split())
li = []
for i in range(n):
    li.append(list(map(int, input().split())))
    del li[i][0]
li = sum(li, [])
li_2 = list(set(li))
count = 0
for num in li_2:
    if n == li.count(num):
        count += 1
print(count)

Solution (Python):
def main():
    row_input = input()
    split_input = row_input.split()

    N = int(split_input[0])
    M = int(split_input[1])

    ansors = []
    for i in range(N):
        row_input = input()
        split_input = row_input.split()
        ansor = []
        for k in range(1, int(split_input[0])+1):
            ansor.append(int(split_input[k]))
        ansors.append(ansor)

    food_list = []
    for i in range(1,M+1):
        food_list.append(i)

    for ans in ansors:
        length = len(food_list)
        diff = 0
        for i in range(length):
            target_food = food_list[i-diff]
            if target_food in ans:
                pass
            else:
                food_list.remove(target_food)
                diff+=1

    result = len(food_list)
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
a = list(map(int, input().split()))
likefood = []
result = 0

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

for i in range(a[1]):
    if likefood.count(i+1) == a[0]:
        result += 1

print(result)

Solution (Python):
n, m = list(map(int,input().split()))
kinds = [0]*m
for i_n in range(n):
  likes = list(map(int,input().split()))
  if likes[0] != 0:
    for j_likes in likes[1:]:
      kinds[j_likes-1]+=1
print(sum([ 1 if kind==n  else 0 for kind in kinds]))

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

for i in range(1,len(favlist[0])):
    notfav.append(favlist[0][i])

for i in range(n):
    favlist[i][0] = 0

if n != 1:
    for i in range(n):
        for j in range(len(notfav)):
            if not notfav[j] in favlist[i]:
                notfav[j] = 0
    cnt = 0
    for i in range(len(notfav)):
        if notfav[i] != 0:
            cnt += 1
    print(cnt)
else:
    print(len(favlist[0]) - 1)

Solution (Python):
from functools import reduce

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

_dict={}

for i in range(N):
  _dict[i] = set(map(int, input().split()[1:]))
  
A = set(range(1, M+1))
A0 = set(range(1, M+1))

def aa(setA, setB):
  return setA & setB
  
print(len(reduce(aa, _dict.values(), A0)))

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

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

people_likes = dict()
for likes in likes_list:
    num = likes[0]
    for i in range(num):
        try:
            people_likes[likes[1:][i]] += 1
        except KeyError:
            people_likes[likes[1:][i]] = 1

count = 0
for v in people_likes.values():
    if v == N:
        count += 1

print(count)

Solution (Python):


N, K = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(N)]

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

set_list = []

for i in e:
    set_list.append(set(i[1:]))


ok = set()
for i in set_list:
    for num, i2 in enumerate(set_list):
        if num == 0:
            continue
        if len(ok) >=1:
            ok = list(i2.intersection(ok))
        else:
            ok = list(i.intersection(i2))
    break

print(len(ok))

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

r = None
for i in range(N):
    temp = list(map(int,input().split()))
    del temp[0]

    if r is None:
        r = set(temp)
    else:
        r = r & set(temp)

print(len(r))

Solution (Python):
N, M= (int(i) for i in input().split())
lst = [[int(i) for i in input().split()] for i in range(N)]
import numpy as np
food = np.zeros((N,M))
for i in range(N):
    for j in range(lst[i][0]):
        
        food[i][lst[i][j+1]-1] = 1

s = np.sum(food, axis=0)
print(len(s[s==N]))

Solution (Python):
import copy
n, m = [int(i) for i in input().split() ]
x = list([])
k = list([])
for i in range(n):
    a = [int(i) for i in input().split() ]
    k.append(a.pop(0))
    x.append(a)

p = copy.deepcopy(x[0])
for i in range(n-1):
    p.extend(x[i+1])
    p = [z  for z in set(p) if p.count(z) > 1]
print(len(p))

Solution (Python):
I=lambda:list(map(int,input().split()))
n,m=I()
a=[]
for _ in[0]*n:a.extend(I()[1:])
print(sum(n==a.count(i+1)for i in range(m)))

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

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

Solution (Python):
I=lambda:list(map(int,input().split()))
n,m=I()
a=[]
for _ in[0]*n:a.extend(I()[1:])
print(sum(n==a.count(i+1)for i in range(m)))

Solution (Python):

import sys

def io_generator():
	while True:
		yield raw_input()




def cc(l1,l2):
	return list(set(l1)&set(l2))

def main(io):
	n,m= map(int, io.next().split())
	favs=range(m+1)
	for _ in range(n):
		l=list(map(int, io.next().split()))[1:]
		favs = cc(favs, l)
			
	return len(favs)



if __name__ == "__main__":
	io=io_generator()
	print main(io)

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

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


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

for i in range(len(a)):
    if i == 0:
        match = set(a[i])
    else:
        target = set(a[i])
        match = set(match & target)

print(len(match))

Solution (Python):
m = input().split()
n = int(m[0])
m = int(m[1])
food = list(range(1,m+1))
for i in range(n):
    inputvalue = input().split()
    del inputvalue[0]
    for j in range(1,m+1):
        if not str(j) in inputvalue and j in food:
            food.remove(j)
print(len(food))

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

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

for i in range(N):
    A = [int(x) for x in input().split()]
    K = A[0]
    for j in range(1,K+1):
        t[A[j]-1] += 1

ans = 0
for a in t:
    if a == N:
        ans += 1

print(ans)

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

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

print(sum(1 for x in d if x == n))

Solution (Python):
N, M = (int(i) for i in input().split())
A = [0] * N
K = [0] * N
for n in range(N):
    A[n] = [int(i) for i in input().split()]
    K[n] = A[n][0]
    A[n] = A[n][1:]
K
A
ans = set(A[0])
for a in A[1:]:
     ans = ans & set(a)
print(len(ans))

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

Solution (Python):
from collections import Counter
n,m=map(int,input().split())
lst=[]
for i in range(n):
    lst.append(list(map(int,input().split())))
    del lst[i][0]
ans=[flatten for inner in lst for flatten in inner]
a=Counter(ans)
count=0
result=list(a.values())
for i in result:
    if i==n:
        count += 1
print(count)

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

field = [] 
for i in range(M):
    field.append([False] * N)

for n in range(N):
    row = list(map(int, input().split()))
    row.pop(0)
    for i in row:
        field[i-1][n] = True

cnt = 0
for m in range(M):
    if all(field[m]):
        cnt += 1
print(cnt)

Solution (Python):
import collections
import sys


def main():
    N, M = map(int, input().split())
    data = []

    for num in range(N):
        result_data = list(input().split(' '))
        if N == 1:
            result = result_data[0]
            print(result)
            sys.exit(0)
        else:
            for i in result_data[1:]:
                data.append(int(i))

    c = collections.Counter(data)

    counter = 0

    for i in c.values():
        if i == N:
            counter += 1

    print(counter)


if __name__ == '__main__':
    main()

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

field = [] 
for i in range(M):
    field.append([False] * N)

for n in range(N):
    row = list(map(int, input().split()))
    row.pop(0)
    for i in row:
        field[i-1][n] = True

cnt = 0
for m in range(M):
    if all(field[m]):
        cnt += 1
print(cnt)

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

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

a = []

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



ans = 0

for j in range(1,M+1):
    cnt_M = 0
    for k in range(N):
        for i in range(1,a[k][0]+1):
            if a[k][i] == j:
                cnt_M = cnt_M + 1
    
    if cnt_M == N :
        ans = ans +1

print(ans)

Solution (Python):


def solve(n, m, *lines):

    
    rows = []
    for line in lines:
        rows.append([int(e) for e in line.split(" ")])

    
    
    

    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():
    
    params = []
    nm = input().split(" ")
    n = int(nm[0])
    m = int(nm[1])
    params.append(n)
    params.append(m)

    for i in range(0, n):
        params.append(input())   
    print(solve(*params))

if __name__ == '__main__':

    main()

Solution (Python):
As,Bs=input().split()
N=int(As)
M=int(Bs)
ans=0

Alist=input().split()
Alist.pop(0)
for i in range(N-1):
    Slist=input().split()
    Slist.pop(0)
    Alist=Alist+Slist

ASlist=list(set(Alist))

for W in ASlist:
    
    if Alist.count(W)==N:
        ans=ans+1
        

print(ans)

Solution (Python):
N,K = map(int, input().split())
list_input = []
food_type = []
food = []
for n in range(N):
    list_input.append(list(map(int,input().split())))
    num = list_input[n][0]+1
    
    each_food = []
    for i in range(1,num):
        
        each_food.append(list_input[n][i])
        if list_input[n][i] in food_type:
            continue
        else:
            
            food_type.append(list_input[n][i])
    food.append(each_food)
ans = 0
for t in food_type:
    all_like = True
    for f in food:
        if t not in f:
            all_like = False
    if all_like:
        ans += 1
print(ans)