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):
    KA = list(map(int,input().split()))
    A.append(KA[1:])

ans = A[0]
for i in range(1,N):
    t = []
    for a in A[i]:
        if a in ans:
            t.append(a)
    ans = t

print(len(ans))

Solution (Python):
N, M = [int(i) for i in input().split()]
ks = list()
for i in range(N):
  ks.append({int(i) for i in input().split()[1:]})
result = set(range(1,M+1)).intersection(*ks)
print(len(result))

Solution (Python):

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


i = 0
j = 0
k = 0
syurui = 0
suki_cnt = [0] * (M + 1)  





for i in range(N):
    for j in range(1,len(KA[i])):
        suki_cnt[KA[i][j]] += 1

for i in range(len(suki_cnt)):
    if suki_cnt[i] == N:        
        syurui += 1
    else:
        pass
    
print(syurui)

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

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

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

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

Solution (Python):


n,m=map(int,raw_input().split())
s=set(range(1,31))
for i in xrange(n):
 l=map(int,raw_input().split())
 s&=set(l[1:])
print len(s)

Solution (Python):
import numpy as np
import math
import sys

n,m = list(map(int, input().split()))
a = np.asarray([])
r = np.asarray([])
for _ in range(n):
    a = np.append(a,(list(map(int, input().split()))[1:]))
for i in range(m):
    r = np.append(r,np.size(a[a==i+1]))

print(np.size(r[r==n]))

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

Solution (Python):

import sys








"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)


"""ここからメインコード"""


def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    n, m = ip.IL()
    res = [[False for _ in r(m)] for _ in r(n)]

    for i in r(n):
        o = ip.IL()
        for j, x in e(o):
            if j != 0:
                res[i][x - 1] = True

    ans = 0
    for i in r(m):
        rr = 0
        for j in r(n):
            if res[j][i]:
                rr += 1
        if rr == n:
            ans += 1

    print(ans)


main()

Solution (Python):
N,M=map(int,input().split())
s=0
a = [list(input().split())for i in range(N)]
for i in range(N):
    del a[i][0]
    a[i]=set(a[i])
c=a[0]
for i in range(N):
    c=c&a[i]
print(len(c))

Solution (Python):
import math
import sys
import random
from operator import itemgetter
input = sys.stdin.readline












N, M = map(int, input().rstrip().split())
ans = []
for i in range(M):
	ans.append(i+1)
ans_set = set(ans)

for i in range(N):
	tmp = list(map(int, input().rstrip().split()))
	ans_set = ans_set & set(tmp[1::])
print(len(ans_set))

Solution (Python):



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

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

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

    result = 0

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

    print(result)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
ans = set(range(1, M+1))
for _ in range(N):
    K, *As = map(int, input().split())
    ans &= set(As)
print(len(ans))

Solution (Python):
n,m = (int(i) for i in input().split())
like = {}
for i in range(n):
    tmp = list(int(i) for i in input().split())
    for j in range(len(tmp)):
        if not j==0:
            if not tmp[j] in like:
                like[tmp[j]] = 1
            else:
                like[tmp[j]] += 1

count = 0
for k, v in like.items():
    if v == n:
        count += 1

print(count)

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

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

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

Solution (Python):
nm = [int(i) for i in input().split()]

tmp = [int(i) for i in input().split()]
tmp2 = tmp[1:]
list = set(tmp2)
for i in range(1,nm[0]):
  tmp = [int(i) for i in input().split()]
  tmp2 = tmp[1:]
  list = set(tmp2) & list 
print(len(list))

Solution (Python):
N, M = map(int, input().split())
preferances = [list(map(int, input().split()))[1:] for _ in range(N)]
all_kind_of_food = [i for i in range(1, M + 1)]
check_for_foods = [i for i in range(1, M + 1)]
for i in range(N):
  for j in range(M):
    if all_kind_of_food[j] in check_for_foods and (not all_kind_of_food[j] in preferances[i]):
      check_for_foods.remove(all_kind_of_food[j])
print(len(check_for_foods))

Solution (Python):
N, M = map(int, input().split())
a = [list(map(int, input().split()))[1:] for _ in range(N)]
b = [i for i in range(1, M + 1)]
c = [i for i in range(1, M + 1)]
for i in range(N):
  for j in range(M):
    if b[j] in c and (not b[j] in a[i]):
      c.remove(b[j])
print(len(c))

Solution (Python):
N, M = map(int, input().split())
a = [sorted(list(map(int, input().split()))[1:]) for _ in range(N)]
b = [i for i in range(1, M + 1)]
c = [i for i in range(1, M + 1)]
for i in range(N):
  for j in range(len(b)):
    if (not b[j] in a[i]) and b[j] in c:
      c.remove(b[j])
print(len(c))

Solution (Python):



def main():
    N, M = [int(a) for a in input().split()]
    A = [
        set([int(a) for a in input().split()][1:])
        for _ in range(N)
    ]

    r = A[0]
    for k in A[1:]:
        r = r.intersection(k)
    print(len(r))


if __name__ == '__main__':
    main()

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

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

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

count = 0
for y in S:
  if y == N:
    count+=1

print(count)

Solution (Python):
n, m = map(int, input().split())
likes = [0] * m
for i in range(n):
    for j in map(int, input().split()[1:]):
        likes[j - 1] += 1
print(len(list(filter(lambda x: x == n, likes))))

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

for i,p in enumerate(people):
    if i == 0:
        most_list = p[1:]
        continue
    tmp = []
    for j in range(1, len(p)):
        if p[j] in most_list:
            tmp.append(p[j])
    if len(tmp) == 0:
        print(0)
        exit()
    most_list = tmp
print(len(most_list))

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

flag = np.zeros(m, dtype = np.int32)
ka = []
for i in range(n):
    ka = np.array(list((map(int, input().split()))))
    ka -= 1
    flag[ka[1:]] += 1
    if np.max(flag) != i + 1:
        print("0")
        exit()
print(len(flag[flag==n]))

Solution (Python):
N, M = map(int, input().split())
like = [0 for _ in range(M + 1)]
for _ in range(N):
    t = list(map(int, input().split()))
    for tt in t[1:]:
        like[tt] += 1
print(sum(1 if x == N else 0 for x in like))

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

Solution (Python):
n, m = map(int, input().split())
l = [str(x) for x in range(1, m + 1)]
i = 0
while (i < n):
    k = [str(x) for x in input().split()]
    del k[0]
    l = list(set(l) & set(k))
    i += 1
print(len(l))

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

s = [0] * m

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

ans = 0
for x in s:
    if x == n:
        ans += 1
print(ans)

Solution (Python):
num_of_person, num_of_foods = map(int, input().split())

if num_of_person == 0:
    print("0")

common_favorit_food_set = set()
for i in range(num_of_person):
    research = list(map(int, input().split()))
    num_of_favorit = research[0]
    favorit_set = set(research[1:])
    if i == 0:
        common_favorit_food_set = favorit_set
    else:
        common_favorit_food_set &= favorit_set


print("{}".format(len(common_favorit_food_set)))

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

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

Solution (Python):
n,m=map(int,input().split())
array=[]
for i in range(n):
    k=input().split()
    k=list(map(int,k))
    array.append(k[1:])
items=[]
s=0
for v in array:
    for item in v:
        items.append(item)  
for i in range(1,m+1):
    cnt=0
    for j in range(len(items)):
        if items[j]==i:
            cnt+=1
    if cnt==n:
        s+=1
print(s)

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

for x in range(1, m+1):
	flag = 1
	for y in l:
		if x not in y:
			flag = 0
	ans += flag
print(ans)

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

r = [0 for x in range(0, m)]

for _ in range(0, n):
    a = [x for x in map(int, input().split())]
    for i in a[1:]:
        r[i - 1] += 1

print('{}'.format(len([x for x in r if x == n])))

Solution (Python):
print(len(set.intersection(*[set(input().split()[1:])for _ in[0]*int(input()[:2])])))

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


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

print(count)

Solution (Python):
N, M = map(int, input().split())
a = {i for i in range(1, M + 1)}
for _ in range(N):
  b = [int(x) for x in input().split()];
  a &= set(b[1:])

print(len(a))

Solution (Python):
n, m = map(int, input().split())
 
a_li =[]
for i in range(n):
    li = input().split()
    del li[0]
    a_li += li
 
count_li =[]
for o in range(m+1):
    x = a_li.count(str(o))
    count_li.append(int(x))
    
print(count_li.count(n))

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

Solution (Python):
from functools import reduce

if __name__ == '__main__':
    n, m = map(int, input().split())
    likes = [set(input().split()[1:]) for _ in range(n)]
    print(len(reduce(lambda x, y: x.intersection(y), likes, set(str(i) for i in range(1, m + 1)))))

Solution (Python):
I=lambda:set(input().split()[1:])
n=int(input()[:2])-1
s=I()
for _ in[0]*n:s&=I()
print(len(s))

Solution (Python):
I=lambda:input().split()
n=int(I()[0])-1
s=set(I()[1:])
for _ in[0]*n:s&=set(I()[1:])
print(len(s))

Solution (Python):
I=lambda:input().split()
n,m=map(int,I())
s=set(I()[1:])
for _ in[0]*~-n:s&=set(I()[1:])
print(len(s))

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

Solution (Python):
import sys
import collections

N = int(sys.stdin.readline().strip().split()[0])

new = []
for i in range(N):
  tmp = sys.stdin.readline().strip().split()
  for j in range(len(tmp)-1):
    new.append(tmp[j+1])

c = collections.Counter(new)


cnt = 0
for i in range(len(c.most_common())):
  if int(c.most_common()[i][1]) == N:
    cnt += 1
  else:
    break
    
print(cnt)

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

Solution (Python):
import collections
n,k = map(int, input().split())
l=[]
for i in range(n):
    x = list(map(int, input().split()))
    l+=x[1:]
c = collections.Counter(l)
s=0
for i in c.most_common():
    
    if n == i[1]:
        s+=1
print(s)

Solution (Python):
N ,M = map(int,input().split())
L = []
import collections as col
for _ in range(N):
    l = list(map(int,input().split()))
    tmp = l.pop(0)
    for x in l:
        L.append(x)
c = list(col.Counter(L).items())
cnt = 0
for x in c:
    if x[1] == N:
        cnt += 1

print(cnt)

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

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

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

print(len(ans))

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

Solution (Python):

n,m = list(map(int,input().split()))
for i in range(n):
    if i == 0:
        a = set(list(map(int,input().split()))[1:])
        continue
    else:
        b = set(list(map(int,input().split()))[1:])
        a = a&b
print(len(a))

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

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

Solution (Python):
from collections import Counter

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

KS= set([])
for i in range(N):
    IA = list(map(int, input().split()))
    if i == 0:
        KS = set(IA[1:])
    else:  
        KS = KS.intersection(set(IA[1:]))

print(len(KS))

Solution (Python):
I=lambda:map(int,input().split())
N,M=I()
R=set(range(1,M+1))
for _ in [0]*N:_,*A=I();R&=set(A)
print(len(R))

Solution (Python):
nb_people, nb_foods = [int(x) for x in input().split()]
like_count = {}
for _ in range(nb_people):
    _, *liked = [int(x) for x in input().split()]
    for i in liked:
        like_count[i] = like_count.get(i, 0) + 1
cnt = 0
for x in like_count.values():
    if x == nb_people:
       cnt += 1
print(cnt)

Solution (Python):



from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

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

t = Counter()
for _ in range(n):
    t += Counter(input().split()[1:])

print(sum(v == n for v in t.values()))

Solution (Python):
N, M = map( int, input().split())
ANS = [1]*(M+1)
ANS[0] = 0
for _ in range(N):
    C = list( map( int, input().split()))[1:]
    for i in range(1, M+1):
        if i in C:
            pass
        else:
            ANS[i] = 0
print( sum(ANS))

Solution (Python):

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

check_list = [False] * M
for i in range(M):
    flag = True
    for j in range(N):
        if i+1 not in l[j][1:]:
            flag = False
    if flag:
        check_list[i] = True

print(check_list.count(True))

Solution (Python):



from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

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

t = Counter()
for _ in range(n):
    t += Counter([int(x) for x in input().split()][1:])

print(sum(v == n for v in t.values()))

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

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

for _ in range(m):
  count.append(0)

for i in range(n):
  for j in range(1, m+1):
      if j in a[i]:
        count[j-1] += 1
      
for _ in range(m):
  if n in count:
    count.remove(n)
    result += 1
      
print(result)

Solution (Python):
n,m = map(int, input().split())
if n == 1:
    print(input().split()[0])
else:
    kdict = {i:0 for i in range(1,m+1)}
    for _ in range(n):
        for i in map(int, set(input().split()[1:])):
            kdict[i] += 1
    print(len([i for i in kdict.values() if i == n]))

Solution (Python):
n, m = map(int, input().split(' '))
ans = [0 for _ in range(m)]
f = 0 
for _ in range(n):
  tmp = map(int, input().split(' ')[1:])
  for num in tmp:
    ans[num - 1] += 1

for num in ans:
  if num == n:
    f += 1
print(f)

Solution (Python):
import sys
count = []
cnt = 0
N,M = map(int,input().split())
for _ in range(N):
    A = input().split()
    count.extend(A[1:])
for _ in range(M+1):
    c = count.count('%d' %_)
    if c == N:
        cnt+=1
print(cnt)

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

Solution (Python):

N, M = map(int, input().split())
r_list = [0]*M
for _ in range(N):
    A_list = list(map(int, input().split()))[1:]
    for a in A_list:
        r_list[a-1] += 1
        
res = 0
for r in r_list:
    if r == N:
        res += 1
print(res)

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, m = LI()
score = [0] * m
for i in range(n):
    A = LI_()
    for a in A[1:]:
        score[a] += 1

print(score.count(n))

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

res = 0
for i in range(1,M+1):
    flag = 1
    for a in A:
        if i not in a:
            flag = 0
            break
    res += flag

print(res)

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

unko = []
for j in range(1,M+1):
     unko.append(j)

count = 0
ans = 0

for k in range(M):
    for l in range(N):
        if unko[k] in KA[l][1:]:
            count += 1
    if count == N:
        ans += 1
    count = 0
        
          
print(ans)

Solution (Python):

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

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

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

food = A.pop(0)
K = food.pop(0)

for i in range(N - 1):
    K = A[i].pop(0)
    food = list(set(food) & set(A[i]))

print(len(food))

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

Solution (Python):
N,M = map(int,input().split())
like = range(1,M+1)
if N == 1:
    A = list(map(int, input().split()))
    print(A[0])
else:
    for i in range(N):
        A = list(map(int, input().split()))
        like = set(like).intersection(A[1:])
        like = list(like)
    print(len(like))

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

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

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

b = [x[1:] for x in a ]

c = []
for j in range(1,31):
    for k in range(n):
        if j in b[k]:
            c.append(j)

d = [x for x in set(c) if c.count(x) == n]

print(len(d))

Solution (Python):
N,M = map(int,input().split())
a = []
for i in range(N):
  array = list(map(int, input().strip().split(' ')))
  a.append(array)
ans = 0
sum = [0]*32
tmp = 0
for i in range(N):
  tmp = a[i][0]
  for j in range(tmp):
    sum[a[i][j+1]] = sum[a[i][j+1]] + 1
    
for i in range(32):
  if sum[i] == N:
    ans = ans + 1
print(ans)

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

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

a = {}
for i in list:
    for j in i[1:]:
        if j in a:
            a[j] = a[j] + 1
        else:
            a[j] = 1

cnt = 0
for x in a.values():
    if x == n[0]:
        cnt += 1

print(cnt)

Solution (Python):
import collections
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
sum_list = []
ans = 0
for i in range(N):
        for x in X[i][1:]:
                sum_list.append(x)
c = collections.Counter(sum_list)
for i in c.values():
        if i == N:
                ans += 1
print(ans)

Solution (Python):
N, M = map(int, input().split(" "))
ary = [0] * M
for i in range(0,N):
    KA = list(map(int, input().split(" ")))
    for a in KA[1:KA[0]+1]:
        ary[a-1] += 1
rtn = 0
for i in ary:
    rtn += i == N
print(rtn)

Solution (Python):
N = list(map(int, input().split()))
array = list(map(int, input().split()))
array.remove(array[0])
dainyu = []
for i in range(0, N[0]-1):
    data = list(map(int, input().split()))
    dainyu = []
    for loop in range(1, data[0]+1):
        if (array.count(data[loop]) != 0) :
            dainyu.append(data[loop])
    array = dainyu
print(len(array))

Solution (Python):
import numpy as np

a = input().split()
b = []
for i in range(int(a[0])):
  c = input().split()
  b.extend(c[1:])
count = 0
  
for j in range(int(a[1])+1):
  check = b.count(str(j))
  if check >= int(a[0]):
    count += 1

print(count)

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

like = [1] * M

for i in range(N):
    K, *A = map(int, input().split())
    for i in range(M):
        if i + 1 not in A:
            like[i] = 0
print(sum(like))

Solution (Python):
import collections
import itertools

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

counter = collections.Counter(a)

ret = [letter for letter,count in counter.most_common() if count == counter.most_common()[0][1]]
if N == counter.most_common()[0][1]:
	print(len(ret))
else:
  print(0)

Solution (Python):
import numpy as np
n, m = map(int, input().split())
A = []
for _ in range(n):
  __ = input().split()
  A.append(np.array(__, dtype=int))
ans = []
for i in range(m):
  ans.append(i+1)
_ans = ans.copy()
for a in A:
  for i in range(len(ans)):
    if not ans[i] in a[1:]:
      _ans.remove(ans[i])
  ans = _ans.copy()
  
print(len(_ans))

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

Solution (Python):

"""
Created on Sat Feb 16 21:09:45 2019

@author: iwata
"""

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

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

if N==1:
    print(len(anew))
else:
    for j in range(1,N):
        a = list(map(int, input().split()))
        for k in range(1, len(a)):
            anew.append(a[k])
        anew_duplicate = [x for x in set(anew) if anew.count(x) > 1]
        anew = anew_duplicate 
    print(len(anew_duplicate))

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

count = [0 for i in range(K)]

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

ans = 0
for i in range(K):
    if count[i] == N:
        ans += 1

print(ans)

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

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

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

for i in range(m):
    all_true = True
    for j in a:
        if (i+1) not in j:
            all_true = False
            break
    if all_true:
        ans[i] = True

print (ans.count(True))

Solution (Python):
N,M = map(int,input().split())
likes = [0]*M
for n in range(N):
    K = [int(i) for i in input().split()]
    A = K[1:]
    for a in A:
        likes[a-1]+=1
result=0
for like in likes:
    if like == N:
        result+=1
print(result)

Solution (Python):
N, M = map(int, input().split())
li = []
for _ in range(N):
    L = [int(x) for x in input().split()]
    li.append(L[1:])



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

print(ans)

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

a_li =[]
for i in range(n):
    li = input().split()
    del li[0]
    a_li += li

count_li =[]
for o in range(m+1):
    x = a_li.count(str(o))
    count_li.append(int(x))
    
print(count_li.count(n))

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

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


for i in range(n):
    line = []
    for part in input().split()[1:]:
        all_like[int(part)-1] += 1



cnt = 0
for part in all_like:
    if part == n:
        cnt += 1

print(cnt)