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=[]
for i in range(N):
  a=list(map(int, input().split()))
 
  a = a[1:]
  
  
  A.append(a)

ans = 0
for i in range(1,M+1): 

  
  found = True
  for j in range(N): 
      if (not i in A[j]): 
          found = False
          break
  if found == True:
      ans += 1

print (ans)

Solution (Python):
import collections
N, M = list(map(int,input().split()))
loves = []
for i in range(N):
    love = list(map(int,input().split()))
    loves.append(love[1:])
lx = []
for l in loves:
    lx.extend(l)
c = collections.Counter(lx)
cnt = 0
for k, v in c.items():
    if v == len(loves):
        cnt += 1
print(cnt)

Solution (Python):
nm=input().split()
N=int(nm[0]);M=int(nm[1])
dict={}
for i in range(N):
    list=input().split()
    del list[0]
    dict[i]=[int(l) for l in list]
st={}
for j in range(N):
    if j==0:
        st=set(dict[j])
    else:
        st=st&set(dict[j])
print(str(len(st)))

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

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

currSet = favFood[0]

for i in favFood:
    currSet = currSet & i

print(len(currSet))

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

for _ in range(N):
    K, *A = map(int, input().split())
    for i in range(M):
        if (i+1) not in A:
            flags[i] = False

print(flags.count(True))

Solution (Python):
from collections import Counter
N,M = map(int,input().split())
l = []
for _ in range(N):
    l += list(map(int,input().split()))[1:]
c1 = Counter(l)
c2 = Counter(c1.values())
if N in c2.keys():
    print(c2[N])
else:
    print(0)

Solution (Python):
from collections import Counter


N, M = map(int, input().split())
ctr = Counter()
for _ in range(N):
    foods = list(map(int, input().split()))[1:]
    for food in foods:
        ctr[food] += 1


print(sum(count == N for count in ctr.values()))

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

food_list=list(range(1,M+1))

for n in range(N):
  input_list=[int(x) for x in input().split()]
  Ans_list = input_list[1:]
  
  Check_list=[x for x in Ans_list if x in food_list]
  food_list = Check_list
  
print(len(Check_list))

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

A = [0] * M
for i in xrange(N):
    K = map(int, raw_input().split())
    for j in xrange(1, len(K), 1):
        A[K[j]-1] += 1

count = 0
for a in A:
    if a == N: count += 1

print count

Solution (Python):
N,M = map(int,input().split())
lss = []
for i in range(N):
    ls = list(map(int,input().split()))
    lss.append(ls[1:])
s = set(range(1,M+1))
for i in range(N):
    s = s.intersection(set(lss[i]))
print(len(s))

Solution (Python):
N,M = map(int,input().split())
c = set(range(M + 1))
for i in range(N):
    a,*b = map(int,input().split())
    c &= set(b)
print(len(c))

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

for i in range(N):
  a = input().split()
  a.pop(0)
  if(i == 0):
    ans = set(a)
  else:
    ans = ans&set(a)
    
len_ans = len(list(ans))
print(len_ans)

Solution (Python):
q=set(map(str,range(31)))
for s in open(0).readlines()[1:]:
    t=set(s.split()[1:])
    q&=t
print(len(q))

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

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

Solution (Python):
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() 

n,m = na()
a = [0]*40
for i in range(n):
  for j in na()[1:]:
    a[j] += 1

print(a.count(n))

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

for i in range(N):
    new_answer_cand = []
    food_list = []
    food_list.extend(list(map(int, input().split())))

    if i == 0:
        answer_cand.extend(food_list)
        answer_cand = answer_cand[1:]
    else:
        for j in range(0, len(answer_cand)):
            for k in range(1, len(food_list)):
                if answer_cand[j] == food_list[k]:
                    new_answer_cand.append(answer_cand[j])
        answer_cand = new_answer_cand

print(len(answer_cand))

Solution (Python):

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

cnt = 0
for i in range(1, M+1):
    jlist = []
    for j in range(N):
        if i in kaito[j][1:]:
            jlist.append(True)
        else:
            jlist.append(False)
    if all(jlist):
        cnt += 1
        
print(cnt)

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

k = [0] * n
a = [0] * n

for i in range(0,n):
    info = input().split()
    k[i] = info[0]
    a[i] = info[1:]

l = a[0][:]
for k in range(1,n):
    new = []
    for x in l:
        if x in a[k]:
            new.append(x)
    l = new[:]

print(len(l))

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

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

l = []

for i in range(N):
  l = [int(j) for j in input().split()]
  K = l.pop(0)
  l = set(l)
  if i > 0:
    l = l & pre_l
  pre_l = l
  
print(len(l))

Solution (Python):
n, m = map(int, input().split())
people =[]
food=[]
for i in range(n):
    people.append(list(map(int, input().split())))
common = {k for k in range(1, 31)}
for j in range(n):
    people[j].pop(0)
    common = common & set(people[j])
print(len(common))

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

Solution (Python):
def main():
    foods_list = get_params()
    print(count_common(foods_list))


def get_params():
    n, _ = map(int, input().split())
    return [
        {a for a in input().split()[1:]}
        for _ in range(n)
    ]


def count_common(foods_list):
    return len(set.intersection(*foods_list))


if __name__ == "__main__":
    main()

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

Solution (Python):
N,M = map(int,input().split())
_,*A = map(int,input().split())
A = set(A)
for i in range(N-1):
    _,*B = map(int,input().split())
    A &= set(B)
print(len(A))

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

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


for j in range(N):
    list_ &= set(a[j][1:])
    

if len(list_) !=0:
    print(len(list_))
else:
    print(0)

Solution (Python):
N,M = tuple(map(int,input().split()))
import numpy as np
like_array = np.zeros((N,M))
for i in range(N):
    _in_ =list(map(int,input().split()))
    K =_in_[0]
    A = _in_[1:]
    for j in A:
        like_array[i,j-1] = 1
print(int(np.sum(np.prod(like_array,axis=0))))

Solution (Python):


import numpy as np
N, M = (int(i) for i in input().split())
KA = [list(map(int, input().split())) for _ in range(N)]



count_list = [0] * M

for A in KA:
    for a in A[1:]:
        
        count_list[a-1] += 1
print(np.sum((np.array(count_list) / N)==1))

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

k = []
list = [0] * m
for i in range(n):
  line = [int(item) for item in input().split()]
  for item in range(m):
    if (item+1) in line[1:]:
      list[item] += 1

num = 0
for item in list:
  if item == n:
    num+=1

print(num)

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

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

count = 0
for k in ans:
  if k == N:
    count += 1
print(count)

Solution (Python):
N, M = map(int, input().split())
D = []
for i in range(1, N + 1):
    ni = [int(_) for _ in input().split()]
    ni = ni[1:]
    D.extend(ni)
E =[]
for j in range(1, M + 1):
    if D.count(j) == N:
        E.append(j)
print(len(E))

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

food = [0] * (M+1)

for _ in range(N):
    L = list(map(int, input().split()))
    L = L[1:]
    for l in L:
        food[l] += 1

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

Solution (Python):



N, M = [int(x) for x in input().split()]
ls =[]
for _ in range(N):
    foodlist = [int(x) for x in input().split()]
    ls += foodlist[1:]

answer = 0
for M  in range(M):
    if ls.count(M +1) == N:
        answer += 1

print (answer)

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

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

count = [0]*M

for i in range(N):
    k = list(map(int,input().split()))
    k = k[1:]
    for kk in k:
        count[kk-1]+=1
total = 0
for l in count:
    if l ==  N:
        total += 1
print(total)

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

i_like_these = input().split()
everyone_likes_these = set(i_like_these[1::])
for n in range(N-1):
    n_likes_these = input().split()
    n_likes_these = n_likes_these[1::]
    everyone_likes_these &= set(n_likes_these)

print(len(everyone_likes_these))

Solution (Python):
l = [int(i) for i in input().split()]
lf = [0]*(l[1]+1)
for i in range(l[0]):
    for j in [int(k) for k in input().split()][1:]:
        lf[j] += 1
print(list(map(lambda x:str(x), lf)).count(str(l[0])))

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

B=[0]*(M+1)

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

print (B.count(N))

Solution (Python):
N,M=map(int,input().split())
Al=[list(map(int,input().split()))[1:] for _ in range(N)]
V=[[False]*M for _ in range(N)]
for row, As in enumerate(Al):
    for A in As:
        V[row][A-1]=True
print(sum([all(f) for f in zip(*V)]))

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

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

for k_a in K_A:
    for a in k_a[1:]:
        result[a-1] -= 1

print(sum(map(lambda x: x == 0, result)))

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())
C = set(list(range(1,M+1)))
for _ in range(N):
    L=list(map(int,input().split()))
    A=L[1:]
    C=C&set(A)
print(len(C))

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

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

inp = input().split(" ")
inp.remove(inp[0])
for i in inp:
  likeNum.append(i)

for n in range(0,N-1):
  inp = input().split(" ")
  inp.remove(inp[0])
  nextInp = []
  for i in inp:
    if i in likeNum:
      nextInp.append(i)
  likeNum = nextInp

print(len(likeNum))

Solution (Python):
def ans():
  N, M = map(int,input().split())
  A = [list(map(int,input().split())) for _ in range(N)]
  d = {}
  cnt = 0
  for a in A:
    for j in range(1,a[0]+1):
      if(a[j] in d):
        d[a[j]] += 1
      else:
        d[a[j]] = 1
      if(d[a[j]] == N):
        cnt += 1
  print(cnt)
ans()

Solution (Python):
n, m = map(int, input().split())
dic_ = {}
for _ in range(n):
    a = list(map(int, input().split()))
    a = a[1:]
    for i in a:
        if i in dic_:
            dic_[i] += 1
        else:
            dic_[i] = 1

ans = 0
for i in dic_.keys():
    if dic_[i] == n:
        ans += 1

print(ans)

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

count_list = []
for x in e:
    count_list += x[1:]

result = 0
for i in range(m):
    if count_list.count(i+1) == n:
        result += 1

print(result)

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

Solution (Python):

n, m = [int(x) for x in input().split()]
a = []
r = set(_ for _ in range(1, m + 1))
for _ in range(n):
    k = [int(x) for x in input().split()][1:]
    a.append(k)
for t in a:
    r &= set(t)
print(len(r))

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

L = list(map(int, input().split()))
S = set(L[1:])

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

print(len(S))

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

count = [0] * m
for i in range(n):
    k = list(map(int, input().split()))
    k = k[1:]
    for kk in k:
        count[kk - 1] += 1
total = 0
for c in count:
    if c == n:
        total += 1
print(total)

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

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

for i in range(N):
    myLIKE = list(map(int,input().split()[1:]))
    for j in ref:
        try:
            if j not in myLIKE:
                LIKE.remove(j)
        except ValueError:
            pass
            
print(len(LIKE))

Solution (Python):
n,m = map(int,input().split())
row = []
count = [0]*m
ans = 0
for it in range(n):
	row.append(list(map(int,input().split())))


for it in range(n):
	for mc in row[it][1:]:
		count[mc-1] += 1
		if count[mc-1] == n:
			ans += 1

print(ans)

Solution (Python):
def foods_loved_by_everyone(N: int, M: int, KA: list) -> int:
    loved = [0] * M

    for ka in KA:
        for a in ka[1:]:
            loved[a-1] += 1

    return sum([1 for l in loved if l == N])


if __name__ == "__main__":
    N = 0
    N, M = [int(s) for s in input().split()]
    KA = [[int(s) for s in input().split()] for _ in range(N)]
    ans = foods_loved_by_everyone(N, M, KA)
    print(ans)

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

Solution (Python):
from functools import reduce
import collections
n, m = map(int, input().split())
a = reduce(lambda a, b: a + b, [input().split()[1:] for _ in range(n)])
c = collections.Counter(a)
print(len([a for a in c.values() if a == n]))

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

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

for _ in range(N):
	k, *A = map(int, input().split())
	R     = R & set(A)

print(len(R))

Solution (Python):
import sys

N,M = map(int,input().split())
member = dict()
for i in range(1,N+1,1):
    ilist = list(map(int,input().split()))
    ilist.pop(0)
    member[i]=set(ilist)

match_set=member[1]

for i in range(2,N+1,1):
    match_set = match_set & member[i]

print(len(match_set))

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

sumamry = [0] * M
for vec in vectors:
    ans = vec[1:]
    for a in ans:
        sumamry[a-1] += 1

ret = 0
for s in sumamry:
    if s == N:
        ret += 1

print(ret)

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

sumamry = [0] * 30
for vec in vectors:
    ans = vec[1:]
    for a in ans:
        sumamry[a-1] += 1

ret = 0
for s in sumamry:
    if s == N:
        ret += 1

print(ret)

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

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

print(ans)

Solution (Python):
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = []
m = []
for i in range(N):
    l.append(stdin.readline().rstrip().split())
    l[i].pop(0)
k = l[N-1]
for i in range(N-1):
    k = set(k)&set(l[i])
print(len(k))

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


list_1st = input().split()[1:]

for i in range(N-1):
  list_tmp = input().split()[1:]
  
  list_1st = [x for x in list_1st if x in list_tmp]

if N == 1:
  print(len(list_1st))
else:
  l_output = [i for i in list_1st if i != ' ']
  print(len(l_output))

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

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

result = [0]*M

for i in range(N):
  foods = map(int, raw_input().split())
  pers_count = foods.pop(0)
  
  for f in foods:
    result[f-1] += 1

res_count = 0
for r in result:
  if N == r:
    res_count += 1

print res_count

Solution (Python):
N, M = map(int, input().split(' '))
cands = None
for _ in range(N):
  items = set(list(map(int, input().split(' ')))[1:])
  if cands is None:
    cands = items
    continue
  else:
    cands &= items
  
  if len(cands) == 0:
    break
print(len(cands))

Solution (Python):
N, M = map(int, input().rstrip().split(' '))
m = {}
for i in range(N):
    row = list(map(int, input().rstrip().split(' ')))
    for j in range(row[0]):
        k = row[1 + j]
        if k in m:
            v = m[k]
            m[k] = v + 1
        else:
            m[k] = 1


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


print(num)

Solution (Python):
N,M = [int(x) for x in input().split()]
ans = 0
fd = [0] * (M + 10)
for i in range(N):
  x, *xs=[int(x) for x in input().split()]
  for j in xs:
    fd[j] += 1
print(len(list(filter(lambda x: x == N, fd))))

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

ans = sum([1 for k, v in count.items() if v == n])
print(ans)

Solution (Python):
import numpy as np

num, kind = map(int, input().split())
foodList = list(range(1, kind+1))

for i in range(num):
    inputList = list(map(int, input().split()))
    inputList.pop(0)
    foodList = list(set(inputList) & set(foodList))

print(len(foodList))

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

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

answer = 0
for c in cnt[1:]:
  if c == N:
    answer += 1
print(answer)

Solution (Python):
N, M = map(int, input().split())
answer = set([])
for i in range(N):
  K_A = [int(x) for x in input().split()]
  K = K_A[0]
  A = K_A[1:]
  if i==0:
    answer = answer.union(set(A))
  else:
    answer = answer.intersection(set(A))

print(len(answer))

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

intersection = None

for _ in range(N):
  nth_list = list(map(int, input().split()))
  nth_list = nth_list[1:]
  nth_set = set(nth_list)
  if intersection is None:
    intersection = nth_set
  else:
    intersection &= nth_set
print(len(intersection))

Solution (Python):
N,M = map(int,input().split())
list = set(list(range(1,M+1)))

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

print(len(list))

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

for k in range(N):
    L = list(map(int,input().split()))
    for e in range(L[0]):
        M[L[1+e]-1] += 1
ans = 0
for e in M:
    if e == N:
        ans += 1
print(ans)

Solution (Python):
import numpy as np

N, M = list(map(int, input().split(' ')))
mat = np.zeros((N, M))
for i in range(N):
  lines = list(map(int, input().split(' ')))
  for j in range(lines[0]):
    mat[i, lines[j+1]-1] += 1

mat_common = np.min(mat, axis=0)
result = np.sum(mat_common)
print(int(result))

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

count = 0

for i in range(1,M+1):
  flg = True
  for list in list_list:
    if i in list[1:]:
      continue
    else:
      flg = False
      break
  if flg == True:
  	count += 1
print(count)

Solution (Python):
n, m = map(int, input().split())
a = set(range(1, m+1))
for _ in range(n):
    _, *ai = map(int, input().split())
    a = a & set(ai)

print(len(a))

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

for i in range(N-1):
	a = list(map(int,input().split()))
	a.pop(0)
	list_ = set(a) & set(list_)

print(len(list_))

Solution (Python):
n,m = map(int, input().split())
q=[input() for i in range(n)]
l=[i+1 for i in range(m)]
l1=[i+1 for i in range(m)]
for i in q:
  t=list(map(int, i.split()))
  for k in l1:
    if (k not in t[1:]):
      if k in l:
      	l.remove(k)
print(len(l))

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

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

def foods(n, k):
    if n == 1:
        return len(k[0]) - 1

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

        next = k[i+1][1:]
        comb = []    

        for j in init[:]:
            if j in next:
                comb.append(j)
        init = comb[:]

    return len(comb)

print(foods(n, k))

Solution (Python):
from collections import Counter
N, M = map(int, input().split())
flags = [True for i in range(M)]
for i in range(N):
    l = list(map(int, input().split()))
    l.pop(0)
    for j in range(M):
        if j + 1 not in l:
            flags[j] = False

print(flags.count(True))

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

Solution (Python):
N, M = [int(i) for i in input().split()]
counter = [0 for i in range(M)]
count = 0
A = []
for i in range(N):
  A.append([int(i) for i in input().split()])
  A[i] = A[i][1:]
  for a in A[i]:
    counter[a - 1] += 1

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

print(count)

Solution (Python):
I=lambda:list(map(int,input().split()))
n,m=I()
from collections import defaultdict
d = defaultdict(int)
for i in range(n):
  a,*b=I()
  for j in b:
    d[j]+=1
print(sum(1 for i in d.values() if i==n))

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

count = [0] * M
for n in range(N):
  KA = list(map(int, input().split()))
  for k in range(KA[0]):
    count[KA[k + 1] - 1] += 1

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

Solution (Python):
N,M = (int(i) for i in input().split())
A = [[int(i) for i in input().split()] for j in range(N)]

ans_List = [1 for i in range(M)]
for i in range(N):
    for j in range(M):
        if j+1 not in A[i][1:]:
            ans_List[j] = 0
ans = 0
for i in ans_List:
    ans += i

print(ans)

Solution (Python):
N, M = map(int, input().split())
m = 0
for i in range(M):
    m += 2**i
for n in range(N):
    k = list(map(int, input().split()))
    k_n = k[0]
    _m = 0
    for i in range(k_n):
        _m ^= 2**(k[i+1]-1)
    m &= _m
ret = bin(m).count("1")
print(ret)

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

print(ans)

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

for i in range(m,1):
    dic[i] = 0


for _ in range(n):
    arr = list(map(int, input().split()))

    for item in arr[1:]:

        if item in dic:
            dic[item] += 1
        else:
            dic[item] = 1

ans = 0
for count in dic.values():
    if count == n:
        ans += 1

print(ans)

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

    for idx in a:
        D[idx-1] += 1

print(D.count(n))

Solution (Python):
import sys
readline = sys.stdin.readline

a = list(map(int,input().split()))
N = a[0]
M = a[1]
cnt = [0,]*(M+1)
ans = 0
for i in range(N):
    K, *like, = readline().split()
    K = int(K)
    like = [int(s) for s in like]
    for j in range(K):
        cnt[like[j]] += 1
for i in range(1, M+1):
    if cnt[i] == N:
        ans += 1
print(str(ans))

Solution (Python):
n, m = map(int, input().split())
survey = [input().split() for i in range(n)]
food = {str(i) for i in range(1, m+1)}

for people in survey:
    del people[0]
    food = food & set(people)

print(len(food))

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

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

for i in range(N):
    L=[int(i) for i in input().split()]
    S=S&set(L[1:])
print(len(list(S)))

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

D = [0] * M

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

    for idx in a:
        D[idx-1] += 1

print(D.count(N))

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

Solution (Python):
n,m=map(int,input().split())
for i in range(n):
    k=[int(j) for j in input().split()]
    t=set([k[j+1] for j in range(k[0])])
    if i==0: l={j for j in t}
    else: l=l&t
print(len(l))

Solution (Python):
n,m=map(int,input().split())
List=[]
kosu=[]
ans=0
for i in range(n):
   k,*a=map(int,input().split())
   List+=a
   kosu.append(k)
for i in range(kosu[0]):
    if List.count(List[i])==n:
        ans+=1
    else:
        ans+=0
print(ans)

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

print(sum(food))

Solution (Python):
N, M = map(int, input().split())
a_dict = {i: 0 for i in range(1, M + 1)}
ans = 0
for i in range(N):
    a_lst = list(map(int, input().split()))
    for j in range(1, a_lst[0] + 1):
        a_dict[a_lst[j]] += 1

for key in a_dict:
    if a_dict[key] == N:
        ans += 1

print(ans)

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

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

Solution (Python):
import sys
 
lines = sys.stdin.read().rstrip().split("\n")
n, m = [int(x) for x in lines[0].split(" ")]
 
result = set(lines[1].split(" ")[1:])
 
if len(lines) == 2:
  print(len(result))
else:
  for x in lines[2:]:
    result = result & set(x.split(" ")[1:])
  print(len(result))

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

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

Solution (Python):
n,m=map(int,input().split())
l=set([i+1 for i in range(m)])
for i in range(n):
    k=[int(j) for j in input().split()]
    t=set([k[j+1] for j in range(k[0])])
    l=l&t
print(len(l))

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

from collections import defaultdict
fav = defaultdict(int)
for i in range(N):
    KA = list(map(int, input().split()))
    for i in range(1, KA[0]+1):
        fav[str(KA[i])] += 1

ans = 0
for i in fav.keys():
    if fav[i] == N:
        ans += 1
print(ans)

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

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

print(len(food_set))

Solution (Python):
import sys

(sn, sm) = sys.stdin.readline().split()
n = int(sn)
m = int(sm)

flg = [0 for j in range(m)]
for i in range(n):
  sa = sys.stdin.readline().split()
  if len(sa) > 1:
    for saj in sa[1:]:
      aj = int(saj)
      flg[aj - 1] += 1

suma = 0
for sumaj in flg:
  if sumaj == n:
    suma += 1
print(suma)

Solution (Python):
from collections import defaultdict

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

L = defaultdict(int)
for i in range(N):
	KA = list(map(int, input().split()))
	for j in range(KA[0]):
		L[KA[1 + j]] += 1

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

print(c)

Solution (Python):
import sys
import collections

a=[]
l = map(int, raw_input().split())
for n in range(l[0]):
    x = map(int, raw_input().split())
    a.extend(x[1:])

c = collections.Counter(a)
values, counts = zip(*c.most_common())
print(counts.count(l[0]))

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

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