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):
s,m=map(int,input().split())
l=[]
for _ in range(s):
  n=[]
  n=list(map(int,input().split()))
  n.pop(0)
  l=l+n
m=dict()
for i in l:
  if i in m:
    m[i]+=1
  else:
    m[i]=1
cnt=0
for j in m:
  if m[j]==s:
    cnt+=1
print(cnt)

Solution (Python):
N,M = map(int, input().split(' '))
ret = {}

for n in range(N):
  p = input().split(' ')
  for k in range(int(p[0])):
    key = p[int(k)+1]
    if key in ret:
      ret[key] += 1
    else:
      ret[key] = 1

print(list(ret.values()).count(N))

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

for i in range(N):
    scan = input().split()
    for x in range(1, len(scan)):
        nums[int(scan[x])] += 1

ans = 0
for i in nums:
    if nums[i] == N:
        ans += 1

print(ans)

Solution (Python):


"""
Created on 2019/2/16
Solved on 2019/2/16
@author: shinjisu
"""



def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def dmp(x):
    global debug
    if debug:
        print(x)
    return x


def probB():
    N, M = getIntList()
    A = getIntMat(N)
    dmp((N, M))
    dmp(A)
    food = set([])
    food = set(A[0][1:])
    dmp(food)
    for i in range(N):
        food2 = set(A[i][1:])
        food = food & food2
        dmp(food)
    return len(food)


debug = False  
print(probB())


def probC():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123


def probD():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123


def probA():
    A, B = getIntList()
    dmp((A, B))
    if B % A == 0:
        return A+B
    else:
        return B-A

Solution (Python):
(n, m) = map(int, input().split())
l = [set(list(map(int, input().split()))[1:]) for _ in range(n)]
print(len(l[0].intersection(*l[1:])))

Solution (Python):
N,M = map(int, input().split())
a = list(map(int, input().split()))
K_past = a[0]
A_past = a[1:]
  

for n in range(1,N):
  a = list(map(int, input().split()))
  l = []
  K = a[0]
  A = a[1:]
  
  for i in range(K):
    if A[i] in A_past:
      l.append(A[i])
  A_past = l
    
print(len(A_past))

Solution (Python):

import sys
import math
import numpy as np
import itertools



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

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


answer = 0
a = [1]*m

for i in range(n):
    b = [0]*m
    for j in range(1,k[i][0]+1):
        b[k[i][j]-1]=1
    for j in range(m):
        if b[j] == 0:
            a[j] = 0



for i in range(m):
    answer += a[i]

print(answer)

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

print(sum([1 for x in foods if x == n]))

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

Solution (Python):
n,m = map(int, input().split())
ref = list(map(int, input().split()))
ref = set(ref[1:])
if n==1:
  print(len(ref))
else:
  for i in range(n-1):
    con = list(map(int, input().split()))
    con = set(con[1:])
    ref = ref&con
    if len(ref)==0:
      break
  print(len(ref))

Solution (Python):
from itertools import chain
n,m = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
for i in x:
    i.pop(0)
x = list(chain.from_iterable(x))
cnt = 0
for i in range(1,m+1):
    if x.count(i)==n:
            cnt += 1
print(cnt)

Solution (Python):
"""
https://atcoder.jp/contests/abc118/tasks/abc118_b
"""

import numpy as np


def parse():
    N, M = list(map(int, input().split()))
    K = np.ones((N, ), dtype=np.int32) * -1
    A = np.ones((N, M), dtype=np.int32) * -1
    for i in range(N):
        tmp = list(map(int, input().split()))
        K[i] = tmp[0]
        A[i, 0:K[i]] = tmp[1:]
    return N, M, K, A


def solve(N, M, K, A):
    nlikes = np.zeros((M + 1,), dtype=np.int32)
    for i in range(N):
        nlikes[A[i, 0:K[i]]] += 1
    print(np.size(np.where(nlikes == N)))


if __name__ == '__main__':
    inputs = parse()
    solve(*inputs)

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

like = {}
for i in range(N):
    first=True
    for i in input().split():
        if first:
            first=False
            continue
        if i in like:
            like[i] += 1
        else:
            like[i] = 1

count = 0
for k in like:
    if like[k] == N:
        count += 1

print(count)

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

A = []
ans = 0
for i in range(N):
    a = [int(x) for x in input().split()]
    a.pop(0)
    A.append(a)

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

print(ans)

Solution (Python):

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


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

cnt = 0
j = 1
for j in range(m+1):
    for k in range(n):
        if suki[k][1:].count(j) == 0:
            break

        if k == (n-1):
            cnt += 1

print(cnt)

Solution (Python):
import collections
n,m=map(int,input().split())
a = []
for i in range(n):
    b = list(map(int, input().split()))
    a.append(b)
c=[]
for i in range(n):
    c.extend(a[i][1:])
co=collections.Counter(c)
s=0
for i in range(m+1):
    if co[i]==n:
        s+=1
print(s)

Solution (Python):
import numpy as np
from collections import defaultdict

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

A = list()
cnt = 0
for i in range(N):
    a = [int(k) for k in input().split()] 
    
    A.append(set(a[1:]))
    pass
for i in range(M):
    i = i+1
    flag = True
    for a in A:
        s = set()
        s.add(i)
        if s <= a:
            pass
        else:
            flag = False
            break
        pass
    if flag == True:
        cnt += 1
    pass

print(cnt)

Solution (Python):
import collections

n, m = [int(s) for s in input().split()]

likes = []
for i in range(n):
    like = [int(s) for s in input().split()]
    likes.append(list(set(like[1:])))


d = set(likes[0])
for like in likes:
    d = d.intersection(set(like))
print(len(d))

Solution (Python):
import numpy as np
a = input()
b = a.split()
N = int(b[0]) 
M = int(b[0]) 
list = []
list_new = []
s = input()
s = s.split()
K = int(s[0])
for i in range(1,K+1):
    list_new.append(int(s[i]))
for i in range(1,N):
    list = list_new
    list_new = []
    s = input()
    s = s.split()
    s = s[1:]
    for item in s:
        if int(item) in list:
            list_new.append(int(item))
        else:
            pass
print(len(list_new))

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

count=0
for i in range(M):
    count1=0
    for j in range(len(K)):
        if i+1 in K[j]:
            count1+=1
    if count1==len(K):
        count+=1

print(count)

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

for m in range(1,M+1):
    for k in K:
        if not m in k[1:]:
            break
    else :
        ans += 1

print(ans)

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

cnt = 0
for i in range(1,M+1):
    for j in range(N):
        
        if i not in A[j][1:]:
            break
    else:
        
        cnt += 1

print(cnt)

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

Solution (Python):
if __name__ == "__main__":
    N, M = [int(i) for i in input().split()]
    dic = {}
    result = 0
    for i in range(N):
        favs = [int(i) for i in input().split()][1:]
        for food in favs:
            num = dic.get(food, 0)
            num += 1
            dic[food] = num
            if num == N:
                result += 1
    print(result)

Solution (Python):
N, M = map(int, input().split(" "))
data = []
for i in range(N):
  A = list(map(int, input().split(" ")))
  A_ = sorted(A[1:])
  data.append(A_)
  
counter = 0  
for m in range(M):
  flag = 1
  for d in data:
    if m+1 in d:
      flag *= 1
    else:
      flag *= 0
  if flag == 1:
    counter += 1

print(counter)

Solution (Python):
n, m = (int(x) for x in input().split())
lis = [0]*m
for i in range(n):
    tmp_lis = [int(x) for x in input().split()]
    del tmp_lis[0]
    for ii in tmp_lis:
        lis[ii-1] += 1
res = 0
for iii in lis:
    if iii == n:
        res += 1

print(res)

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

tmp = set(food[0][1:])
for i in range(1, n):
    tmp = tmp & set(food[i][1:])
print(len(tmp))

Solution (Python):

N, M = list(int(i) for i in input().split())


K = {}
for i in range(0, N):
    tmp_list =  list(int(i) for i in input().split())
    K[i] = tmp_list



foods_set = set(K[0][1:])
for i in range(1, N):
    foods_set = set(foods_set) & set(K[i][1:])
    result = len(foods_set)
    if(result == 0): 
        break

print(len(foods_set))

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

loved = []
for i in range(m):
    loved.append(0)
for i in range(n):
    for f in range(ans[i][0]+1):
        if f==0:
            continue
        loved[ans[i][f]-1] += 1

a = 0

for f in range(m):
    if(loved[f]==n):
        a += 1
print(a)

Solution (Python):

"""
Created on Sat Feb 16 20:59:16 2019

@author: doppe
"""

N, M = map(int, input().split())
likeList = []

for i in range(0, N):
    L = [int(i) for i in input().split()]
    likeListTmp = []
    if (i == 0):
        likeList = L[1 : L[0] + 1]
    else:
        for j in range(1, L[0] + 1):
            if (L[j] in likeList):
                likeListTmp.append(L[j])
        likeList = likeListTmp

print(len(likeList))

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

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

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

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

print(len(K))

Solution (Python):
import numpy as np
from sys import stdin
N,M=[int(x) for x in stdin.readline().rstrip().split()]
a=[]
for i in range(N):
    a.append([int(x) for x in stdin.readline().rstrip().split()])

res=set(list(range(1,M+1)))
for data in a:
  
  res=res&set(data[1:])
print(len(res))

Solution (Python):


if __name__ == '__main__':
    N, M = map(int, input().split())
    set_list = [set(list(map(int, input().split()))[1:]) for i in range(N)]
    if len(set_list) == 1:
        print(len(set_list[0]))
    else:
        _intersect = set_list[0]
        for _set in set_list[1:]:
            _intersect = _intersect.intersection(_set)
        print(len(_intersect))

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

print(likes.count(N))

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

for _ in range(n):
    temp_left = []
    temps = list(map(int, input().split()))
    n = temps[0]
    
    for j in range(1, n+1):
        
        
        if temps[j] in left_foods:
            temp_left.append(temps[j])
    left_foods = temp_left
print(len(left_foods))

Solution (Python):
N, M = map(int, input().split())
i = 0
li = []
while i < N:
    try:
        li.append(list(map(int, input().split())))
    except:
        break
    i += 1

if 1 == len(li):
    del(li[0][0])
    print(len(li[0]))
else:
    temp = []
    for i in range(N):
        del(li[i][0])
        if i == 0:
            temp = list(set(li[i]) & set(li[i+1]))
        else:
            temp = list(set(li[i]) & set(temp))

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

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

count=0
for i in range(M):
    count1=0
    for j in range(N):
        if A[j].count(i+1)==1:
            count1=count1+1
    if count1==N:
        count=count+1
    
print(count)

Solution (Python):
N,M=map(int,input().split())
kekka=[]
for i in range(N):
    li=list(input().split())
    li=[int(s) for s in li]
    li=li[1::]
    
    if i==0:
        base=li
    else:
        kekka.append(li)
count=1
summ=0
for j in base:
    for i in range(N-1):
        if j in kekka[i]:
            count+=1
        
    summ+=count//N
    count=1
        
print(summ)

Solution (Python):
n,m = map(int,input().split())
num = [0] * (m+1)
setn = []
sum = 0
for i in range(n):
    setn = list(map(int,input().split()))

    for j in range(setn[0]):
        box = setn[j+1]
        num[box] = num[box] + 1

for x in range(len(num)):
    if num[x] == n:
        sum += 1

        
print(sum,end="")

Solution (Python):
import fileinput


def algorithm(n, m, a):
    foods = set(a[0][1:])
    for f in a[1:]:
        foods &= set(f[1:])
    return len(foods)


def pass_inputs(input_lines):
    n, m = input_lines[0]
    return algorithm(n, m, input_lines[1:])


def convert_int(s):
    try:
        r = int(s)
    except ValueError:
        r = s
    return r


def run():
    out = pass_inputs([[convert_int(v) for v in l.strip().split(" ")] for l in fileinput.input()])
    print(out)


if __name__ == "__main__":
    run()

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

if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    pass
    '''初期値設定'''
    N, M = [int(i) for i in input().split()]
    food = [0 for i in range(M + 1)]
    '''好み調査開始'''
    for i in range(N):
        p = [int(m) for i, m in enumerate(input().split()) if i != 0]
        for f in p:
            food[f] += 1
    '''結果出力'''
    print(food.count(N))


if __name__ == '__main__':
    solve()

Solution (Python):
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
l = []
for i in range(N):
    l += IL()[1:]

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

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

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

Solution (Python):
n, m = map(int, raw_input().split())
ma = []
num = 0
for i in range(n):
    x = []
    x = map(int, raw_input().split())
    ma.append(x[1:])
ma = sum(ma,[])
for mb in list(set(ma)):
    if ma.count(mb) == n:
        num+=1
print(num)

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

like_list = [val for val in like_dict.values() if val == n]

print(len(like_list))

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

Solution (Python):
n,m = map(int,input().split())
foods = {i:0 for i in range(1, m+1)}
for i in range(n):
  tmp_list = list(map(int,input().split()))
  for j in range(len(tmp_list)):
    if j>0:
      a = tmp_list.pop(1)
      foods[a] += 1
  del tmp_list
ans = [v for v in foods.values() if v==n] 
print(len(ans))

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

if N == 1:
    print(len(A[0]))
else:
    ans = 0
    idx = K.index(max(K))
    max_len = A.pop(idx)
    for j in max_len:
        flg = 0
        for vals in A:
            if j in vals:
                flg += 1
        else:
            if flg == len(A):
                ans += 1
    else:
        print(ans)

Solution (Python):
n,m = input().split()
N = int(n)
M = int(m)
k = []
for i in range(N):
    s = input().split()
    s = [int(i) for i in s]
    s.pop(0)
    k += s
likesum = 0
for i in range(1,M+1):
    if k.count(i) == N:
        likesum += 1
print(likesum)

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

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

print(len([i for i in range(M) if array[i] == N]))

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

  
  result = set([i for i in range(31)])
  for ans in anss:
    result = result & ans

  print(len(result))
  

main()

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

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

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

print(ans)

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

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

Count = 0
for i in range(len(k[0])):
	count = 0
	for j in range(1, len(k)):
		if k[0][i] in k[j]:
			count += 1
			continue
		else:
			break
	if count == n - 1:
		Count += 1
print(Count)

Solution (Python):
def main():
    N, M = map(int, input().split())
    all = list(map(int, input().split()))
    all.pop(0)
    tmp = []
    for _ in range(N - 1):
        tmp.clear()
        tmp = list(map(int, input().split()))
        tmp.pop(0)
        all = list(set(tmp) & set(all))
    print(len(all))


if __name__ == "__main__":
    main()

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

x = A[0]
for a in A[1:]:
  x = list(set(x) & set(a))

print(len(x))

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

ans=0
for mi in range(1,m+1):
    if all(mi in ai[1:] for ai in a):
        ans+=1
print(ans)

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

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

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

score = [0 for _ in range(m)]
for i in a:
    for food_index in i:
        score[food_index - 1] += 1
print(score.count(n))

Solution (Python):


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

fuga = [0]*M
for i in range(N):
    tmp = [int(j) for j in input().split()]
    k = tmp[0]
    s = tmp[1:]
    for i in range(k):
        fuga[s[i]-1] += 1

print(fuga.count(N))

Solution (Python):
N, M = map(int, input().split())
K = [0]*N
A = [[0]*M for i in range(N)]
for i in range(N):
  x = list(map(int, input().split()))
  K[i] = x[0]
  A[i] = x[1:]
l = A[0]
for i in range(1, N):
  j = 0
  max_j = len(l)-1
  j = 0
  while(j != max_j+1):
    if l[j] not in A[i]:
      del l[j]
      max_j -= 1
      j -= 1
    j += 1
print(len(l))

Solution (Python):
n, m = [int(i) for i in input().split()]
a_s = [{int(i) for i in input().split()[1:]} for _ in range(n)]
t = {int(i) for i in range(1, m + 1)}

for a in a_s:
    t = t & a

print(len(t))

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

count = {}

for i in range(n):
	for j in inputs[i]:
		if j in count.keys():
			count[j] += 1
		else:
			count[j] = 1

total = 0
for keys in count:
	if count[keys] == n:
		total += 1
print(total)

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

Solution (Python):
N,M = [int(x) for x in input().split(' ')]
MLIS = [0] * M
for i in range(N):
  p = [int(x) for x in input().split(' ')]
  for j in range(1,p[0]+1):
    
    MLIS[p[j]-1] += 1
    
    
cnt = 0
for i in range(M):
  
  if MLIS[i] == N:
    cnt +=1
print(cnt)

Solution (Python):

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

Ans_i = set(A[0])
for i in range(N):
  Ans_i = Ans_i & set(A[i])
print(len(list(Ans_i)))

Solution (Python):
N, M = list(map(int, raw_input().split()))
K = []

array = []
for i in xrange(M): array.append(0)
for i in xrange(N):
    inputs = list(map(int, raw_input().split()))
    K = inputs[0]
    for j in xrange(K):
        array[inputs[j+1]-1] += 1

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

print str(count)

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

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

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

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

for i in range(n):
    line = [int(t) for t in input().split()]
    k = line[0]
    a = line[1:]
    for item in a:
        food[item - 1] += 1
        
cnt = 0
for item in food:
    if item == n:
        cnt += 1

print(cnt)

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

x=[]

for i in range(n):
  x=x+e[i][1:]


ans=0
if n==1:
  ans=e[0][0]
else:
  for i in range(1,m+1):
    if x.count(i)==n:
      ans+=1
    
print(ans)

Solution (Python):
import numpy as np
n,m = map(int,input().split())
data = np.array([[int(i) for i in input().split()]for j in range(n)])
ans = []
for i in data:
  for j in i[1:]:
    ans.append(j)
ans = np.array(ans)
count = 0
for i in range(1,m+1):
  if (ans==i).sum() == n:
    count +=1
    
print(count)

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

data = []
for i in range(num):
    taste = [int(i) for i in input().split()]
    del taste[0]
    data.append(taste)


result = 0
if len(data) == 1:
    result = len(data[0])
else:
    for num1 in data[0]:
        trueNum = 0
        for i in range(1, len(data)):
            if num1 in data[i]:
                trueNum += 1
                if trueNum == len(data) - 1:
                    result += 1

print(result)

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

Knk=[]
for _ in range(N):
    Knk.append([int(x) for x in input().strip().split()])

ans = [0] * M

for i,Kn in enumerate(Knk):
    for n,A in enumerate(Kn):
        if n == 0:
            continue
        ans[A-1]+=1

print(len([x for x in ans if x == N]))

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

Solution (Python):
import numpy as np
N, M = map(int, input().split())
menu = np.array([])
for i in range(N):
  a = np.array(input().split())
  menu = np.append(menu, a[1:])
menu = np.array(menu).astype(int).ravel()
count = 0
for i in range(1, M+1):
  if np.sum(menu == i) == N:
    count += 1
print(count)

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

table = [True for _ in range(m)]



ans = 0
for i in range(n):
    like = list(map(int , input().split()))[1:]
    
    for j in range(m):
        if j+1 in like:
            pass
        else:
            table[j]=False

for is_liked in table:
    if is_liked:
        ans +=1
print(ans)

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

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

sum=0
for i in range(M):
    for j in range(N):
        if (not((i+1) in A[j])):
            break
        if (j==N-1):
            sum+=1
            
            

print(sum)

Solution (Python):

"""
https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a
"""

from collections import defaultdict
def sol(n, m, Ss):
    stack = defaultdict(int)
    all_like = 0

    for S in Ss:
        
        for i, s in enumerate(S):
            if i == 0: continue
            
            stack[s] += 1
            
            if stack[s] == n:
                all_like +=1
    return all_like



test = False

if test:
    n, k = 3, 4
    Ss = [
        [2, 1, 3],
        [3, 1, 2, 3],
        [2, 3, 2]
    ]
    
    print(sol(n, k, Ss))


else:
    n, k = map(int, input().split())
    
    Ss = []
    for i in range(n):
        S =list( map(int, input().split()))
        Ss.append(S)
    print(sol(n, k, Ss))

Solution (Python):
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
s = None
for d in data:
    if s is None:
        s = set(d[1:])
    else:
        s = s & set(d[1:])
print(len(s))

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

for i in range(n):
    fav_list.append(list(map(int,input().split())))
    
common = fav_list[0][1:]
for i in range(len(fav_list) ):
    common = set(common) & set(fav_list[i][1:])
    
print(len(common))

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

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

init = set(range(1, m+1))
for i in range(n):
	l = list(map(int,input().split()))
	l.pop(0)
	ls = set(l)
	init = init & ls

print(len(init))

Solution (Python):
n,m  = list(map(int, input().split()))
k = list(list(map(int, input().split())) for _ in range(n))
c = 0

for i in range(m):
    f = 0
    for j in range(n):
        if not i+1 in k[j][1:]:
            f = 1
            
            
    if f == 0:
        c += 1

print(c)

Solution (Python):
n, m = map(int, raw_input().split())
ln = []
for k in range(n):
    a = map(int, raw_input().split())
    ln.append(a[1:])
clist = []
for j in range(1, m+1):
    c = 0
    for i in range(len(ln)):
        if j in ln[i]:
            c += 1 
        else:
            break
    clist.append(c)
print clist.count(n)

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

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

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

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

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

like = []
for i in range(m):
  like.append(0)

for i in range(n):
  for j in range(a[i][0]):
    like[a[i][j + 1] - 1] += 1
    
for i in range(m):
  if like[i] == n:
    cnt += 1
    
print(cnt)

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

set_ = [set(tab[i][1:]) for i in range(N)]
for i in range(N):
    if i==0:
        new_set = set_[i]
    if i == N:
        break
    new_set = new_set & set_[i]

print(len(new_set))

Solution (Python):
n, m = list(map(int,input().split()))
count = 0
lis = []


for i in range(n):
  lis.append(list(map(int,input().split())))
  lis[i].pop(0)
   
for i in range(m):
  for k in range(n):
    if not i+1 in lis[k]:
      break
  else:
    count += 1

print(count)

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

a=[]
cnt=[0]*m
ans=0

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

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

Solution (Python):
N, M = map(int, input().split())
K_A = []
M_A  =[0 for _ in range(M)]
ans = 0
for i in range(N):
	k_a = map(int, input().split())
	K_A.append(list(k_a))
for i in range(N):
	for j in range(1, len(K_A[i])):
		M_A[K_A[i][j]-1] += 1
for i in range(len(M_A)):
	if M_A[i] == N:
		ans += 1
print(ans)