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



Sample input:
3 4
2 1 3
3 1 2 3
2 3 2


Sample output:
1

Submission status: Accepted

Solution code:
#h=int(input())
n,m=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

dic={}
ans=0
for i in range(n):
    templ=list(map(int,input().split()))
    k=templ[0]
    for j in range(k):
        a=templ[1+j]
        dic[a]=dic.get(a,0)+1
for k in dic.keys():
    if dic[k]==n:
        ans+=1
print(ans)

Submission status: Accepted

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

for i in range(n):
    if i == 0:
        k = list(map(int, input().split()))[1:]
        k = set(k)

    else:
        tmp = list(map(int, input().split()))[1:]
        tmp = set(tmp)
        k = k & tmp

print(len(k))

Submission status: Accepted

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

Submission status: Accepted

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

l = []
for i in range(n):
  a = [int(x) for x in input().split()]
  for j in range(1, a[0] + 1):
    l.append(a[j])

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

print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    del ls[i][0]
Ls = []
for i in range(m):
    a = 0
    for j in range(n):
        a += ls[j].count(i+1)
    Ls.append(a)
print(Ls.count(n))

Submission status: Accepted

Solution code:
N,M=map(int,input().split(' '))
like = [0]*M
for i in range(N):
    for j in list(map(int,input().split(' ')))[1:]:
        like[j-1]+=1
print(like.count(N))

Submission status: Accepted

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.readline().split()))
    FOODS = set(range(1, M + 1))

    for n in range(N):
        K, *A = list(map(int, sys.stdin.readline().split()))
        FOODS &= set(A)

    print(len(FOODS))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
menu = {}

for i in range(n):
  a = list(map(int, input().split()))
  for j in range(1, len(a)):
    if a[j] in menu:
      menu[a[j]] += 1
    else:
      menu[a[j]] = 1

count = 0
for i in menu:
  if menu[i] == n:
    count+=1
print(count)

Submission status: Accepted

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

print(sum(i == n for i in cnt))

Submission status: Accepted

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

foods = [0] * M
for _ in range(N):
  likes = list(map(int, input().split()))
  for lk in likes[1:]:
    foods[lk-1] += 1

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=0
b=[0]*m
for _ in range(n):
    aa=list(map(int,input().split()))
    aa=aa[1:]
    for i in aa:
        b[i-1]+=1

for i in b:
    if i==n:
        ans+=1

print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
S=set(range(1,m+1)) #1~mの集合
for _ in range(n):
    k,*A=map(int,input().split())
    S &=set(A)
print(len(S))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans = False
for _ in range(N):
    tmp = list(map(int, input().split()))
    k = tmp[0]
    a = set(tmp[1:])
    if ans is not False:
        ans = ans & a
    else:
        ans = a
print(len(ans))

Submission status: Accepted

Solution code:
#ABC118

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
L = [LIST() for i in range(N)]
a = set([i + 1 for i in range(M)])
for l in L:
    s = set(l[1:])
    a &= s
print(len(a))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
from collections import Counter
c = Counter()
for a in A:
    c += Counter(a[1:])
ans = 0
for v in c.values():
    if v==N: ans += 1
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    ans = [1]*m
    for i in range(n):
        q = LI()
        for j in q[1:]:
            ans[j-1] += 1
        for j in range(m):
            ans[j] -= 1
    res = 0
    for i in ans:
        if i == 1:
            res += 1
    print(res)    
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
def examA():
    N = I()
    if N%2==1:
        print("Red")
    else:
        print("Blue")
    return

def examB():
    N, M = LI()
    D = [True]*M
    for _ in range(N):
        A = LI()
        cur = [False]*M
        for a in A[1:]:
            cur[a-1] = True
        for i in range(M):
            if not cur[i]:
                D[i] = False
    ans = 0
    for d in D:
        if d:
            ans += 1
    print(ans)
    return

def examC():

    return

def examD():

    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
aa = [0] * m
for _ in range(n):
    tmp = list(map(int , input().split()))
    for ai in tmp[1:]:
        aa[ai-1] += 1

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

Submission status: Accepted

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

K,*A = map(int,input().split())
ans = set(A)
for _ in range(N-1):
    K,*A = map(int,input().split())
    ans &= set(A)

print(len(ans))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
res = [0 for _ in range(m)]
for _ in range(n):
    ka = [int(i) for i in input().split()]
    k = ka[0]
    a = ka[1:]
    for i in range(k):
        res[a[i]-1] += 1
ans = 0
for i in range(m):
    if res[i] == n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int,input().split())))
fav=[0]*m
for tmp in l:
    for food in tmp[1:]:
        fav[food-1]+=1
ans=0
for f in fav:
    if f == n:
        ans+=1
print(ans)

Submission status: Accepted

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


arr = [0] * m

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

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

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

print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, m = map(int, input().split())
  flags = numpy.zeros((n, m))
  for i in range(n):
    for a in list(map(int, input().split()))[1:]:
      a -= 1
      flags[i, a] = 1
  
  count = 0
  for j in range(flags.shape[1]):
    if sum(flags[:, j]) == n:
      count += 1
  print(count)

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
for i in range(n):
    if i==0:
        l = list(map(int,input().split()))
        l.pop(0)
    else:
        l_tmp = list(map(int,input().split()))
        l_tmp.pop(0)
        l = list(set(l)&set(l_tmp))
print(len(l))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[]
for _ in range(n):
    k,*s=input().split()
    l+=s
se=set(l)
a=0
for i in se:
    c=l.count(i)
    if c==n:
        a+=1
print(a)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
klist = []
alist = []
for i in range(n):
    ret = list(map(int, input().split()))
    klist.append(ret[0])
    alist.append(ret[1:])

snum = [0] * m
for i in range(n):
    for j in alist[i]:
        snum[j-1] += 1

print(snum.count(n))

Submission status: Accepted

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

food = []
for x in range(N):
    ka = list(map(int, input().split()))
    a = ka[1:]
    if x == 0:
        food = a
    else:
        food = list(set(food) & set(a))
print(len(food))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
favorites = set(i for i in range(1, M + 1))
for _ in range(N):
    K, *fav = map(int, input().split())
    favorites = favorites & set(fav)
print(len(favorites))

Submission status: Accepted

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

P = [0]*M

for i in range(N):
    for j in A[i]:
        P[j-1] += 1

cnt = 0
for i in P:
    if i==N:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
K, A = [0] * N, [0] * N
for i in range(N):
    K[i], *A[i] = list(map(int, input().split()))
k = set(i for i in range(1, M + 1))
ki = k.intersection(*A)
print(len(ki))

Submission status: Accepted

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

count = {}
for i in range(1, m + 1):
  count[i] = 0

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

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

print(ans)

Submission status: Accepted

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


result = {i : 0 for i in range(1, M+1)}

for i in range(1, M+1):
  dislike =False
  for j in range(N):
    if not i in K[j][1:]:
      dislike = True
  if not dislike:
    #print(i)
    result[i] = 1
    
print(sum(result.values()))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
cnt=[0]*M
for i in range(N):
    for a in [int(i) for i in input().split()][1:]:
        cnt[a-1]+=1
res=0
for c in cnt:
    if c==N:
        res+=1
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

n, m = map(int, input().split())
l = [list(map(int, input().split()))[1:] for _ in range(n)]
#1次元に変換
r = []
for row in l:
  for i in row:
    r.append(i)
c = dict(Counter(r))
ans = 0
for value in c.values():
  if value == n:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


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

Submission status: Accepted

Solution code:
import copy
n, m = map(int, input().split())
for i in range(n):
    a = list(map(int, input().split()))
    a_set = set(a[1:]) 
    if i == 0:
        base = copy.copy(a_set)
    else:
        base &= a_set
        # answer = len(base)
    # print(base)
    # for j in range(1, a[0]+1):
    #     if a[j] in base:
    #         continue
    #     else:
    #         answer -= 1
print(len(base))

Submission status: Accepted

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

food = [0] * (m+1)

# print(ka)

for i in range(n):
    for j in range(1,ka[i][0]+1):
        # print(ka[i][j])
        food[ka[i][j]] += 1
    # print("--------")

ans = 0
for _food in food:
    if _food == n:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n,m = map(int,input().split())
dish = [0 for i in range(m)]
for i in range(n):
    s = list(map(int,input().split()))
    k = s[0]
    a = []
    for j in range(1,k+1):
        a.append(s[j])
    for j in range(len(a)):
        dish[a[j]-1]+=1
    a.clear()
cnt = 0
for i in range(len(dish)):
    if dish[i] == n:
        cnt+=1
print(cnt)

Submission status: Accepted

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

Anew=set(A[0])
for i in range(1,N):
    Anew=Anew.intersection(set(A[i]))

print(len(Anew))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A_li = [list(map(int, input().split())) for i in range(N)] 
K_li = [A_li[i].pop(0) for i in range(N)]
ans = 0
for i in range(M) :
    for j in range(N) :
        if not i + 1 in A_li[j] :
            break
        if j == N - 1 :
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
x = []
c = 0
for i in range(n):
    a = list(map(int,input().split()))
    a.pop(0)
    x.extend(a)

for j in range(1,m+1):
    if x.count(j) == n:
        c += 1

print(c)

Submission status: Accepted

Solution code:
s=list(map(int,input().split()))
t=[list(map(int,input().split())) for i in range(s[0])]
u=[0]*(s[1]+1)
for i in range(s[0]):
  for j in range(t[i][0]):
    a=t[i][j+1]
    u[a]+=1
b=0
for k in range(len(u)):
  if u[k]==s[0]:
    b+=1
print(b)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

for i in range(n):
    k,*a=map(int,input().split())
    for g in range(k):
        d[a[g]]+=1

ans=0
for i,l in d.items():
    if l==n:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
x = []
c = 0
for i in range(n):
    a = list(map(int,input().split()))
    a.pop(0)
    x.extend(a)

for j in range(1,m+1):
    if x.count(j) == n:
        c += 1

print(c)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
c = list(map(int, input().split()))
A = set(c[1:])
for i in range(n-1):
	t = list(map(int, input().split()))
	A &= set((t[1:]))
print(len(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
KA = [list(map(int,input().split())) for i in range(N)]

menu = [0 for _ in range(M+1)]

for i in range(N) :
    for j in range(KA[i][0]) :
        menu[KA[i][j+1]] += 1

from collections import Counter
dict_M = Counter(menu)

print(dict_M[N])

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
cook = [0 for i in range(m+1)]
for i in range(n):
    k = [int(k) for k in input().split()]
    for j in range(k[0]+1):
        if j==0:
            continue
        else:
            cook[k[j]]+= 1

print(cook.count(n))

Submission status: Accepted

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

dp = [0]*m

for _ in range(n):
    t = list(map(int,input().split()))
    a = t.pop(0)
    for i in range(a):
        dp[t[i]-1] += 1
ans = 0
#print(dp)
for i in dp:
    if i == n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
people, menu = map(int, input().split())

base = [int(i) for i in input().split()]
base.pop(0)

d = {}
for b in base:
    d[b] = 1

for _ in range(people-1):
    tmp = [int(i) for i in input().split()]
    tmp.pop(0)
    for t in tmp:
        if t in d:
            d[t] += 1


cnt = 0
for v in d.values():
    if v == people:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(1, m+1):
    tl = []
    for j in range(len(l)):
        tl.append(i in l[j][1:len(l[j])])
    if False not in tl:
        ans += 1
print(ans)

Submission status: Accepted

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

ans = set([i for i in range(1, M+1)])
for _ in range(N):
    tabemono = list(map(int, input().split()))
    tabemono = set(tabemono[1:])
    ans = ans & tabemono

print(len(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#----------
N,M = list(map(int, input().rstrip().split()))
#----------
M_dic={}

for i in range(1,M+1):
    M_dic[i]=0

for i in range(N):
    K,*A_list = list(map(int, input().rstrip().split()))
    
    for a in A_list:
        M_dic[a] += 1

count=0
for m_v in M_dic.values():
    if m_v == N:
        count += 1

print(count)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A_list = []
for i in range(N):
    A = list(map(int, input().split()))
    A_list.append(A)
dic_A = {}
for A in A_list:
    for j in range(1, len(A)):
        if A[j] in dic_A:
            dic_A[A[j]] += 1
        else:
            dic_A[A[j]] = 1
cnt = 0
for i in range(1, M+1):
    if i in dic_A and dic_A[i] == N:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#118_B
N,M=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N)]
cnt=0
for m in range(1,M+1):
    if all(A[n][1:].count(m)>0 for n in range(N)):
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
def solve():
    N, M = [int(_) for _ in input().split()]
    A = []
    for i in range(N):
        k, *a = map(int, input().split())
        A.append(set(a))
    res = set(range(1, M + 1))
    for i in range(N):
        res &= A[i]
    return len(res)
if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

sum=0
for j in range(m):
    flg=True
    for i in range(n):
        #print(a[i])
        if a[i].count(j+1)==0:
         flg=False   
    if flg:
        sum+=1

print(sum)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

A = {}
for i in range(N):
  KA = list(map(int, input().split()))
  for a in KA[1:]:
    if a in A:
      A[a] += 1
    else:
      A[a] = 1


ans = 0
for a in A:
  if A[a] == N:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
count=0                   
total_list = []          
for i in range(1,n+1):
           l_i=list(map(str,input().split()))
           l_i_ = l_i[1:]
           for j in l_i_:
                       total_list.append(j)
s=list(set(total_list))
for a in range(len(s)):
            if total_list.count(s[a]) ==n:
                        count+=1
print(count)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
K = [0] * N
A = [None] * N
items = {}

for i in range(1, M+1):
  items[i] = 0

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

for i in range(N):
  for j in range(len(A[i])):
    items[A[i][j]] += 1

print(len([v for v in items.values() if v == N]))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
S = set(range(1,M+1))
for _ in range(N):
    ka = list(map(int,input().split()))
    A = set(ka[1:])
    S = S&A
print(len(S))

Submission status: Accepted

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

Submission status: Accepted

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

from collections import defaultdict
d = defaultdict(int)
for _ in range(n):
    A = list(map(int, input().split()))
    k, A = A[0], A[1:]
    for a in A:
        d[a] += 1

ans = 0
for v in d.values():
    if v == n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
s = [input().split() for _ in range(N)]

ans = set(s[0][1:])
for l in s[1:]:
    ans = ans & set(l[1:])
print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=[]
for i in range (N):
	A.append(list(map(int,input().split())))
B=[]
count=0
ans=0
for i in range (N):
	for j in range (1,A[i][0]+1):
		B.append(A[i][j])
for i in range (M+1):
	count=0
	for j in range (len(B)):
		if B[j]==i:
			count+=1
	if count==N:
		ans+=1
print(ans)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=[0]*(M+1)
cnt=0
for i in range(N):
  S=list(map(int,input().split()))
  for j in range(1,S[0]+1):
    A[S[j]]+=1
    #print(A)
#print(A)
for i in range(len(A)):
  if A[i]>=N:
    cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
t = []

g = 0
if n == 1:
    print(len(input().split()) - 1)
    exit()

for i in range(n):
    t.append(input().split())

for i in sorted(t, reverse = True)[0][1:]:
    c = 0
    for j in sorted(t, reverse = True)[1:]:
        
        if j[1:].count(i) == 1:
            c += 1

        if c == n - 1:
            g += 1

print(g)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
flag = [0]*m
for i in range(n):
    a = list(map(int,input().split()))
    for j in a[1:]:
        flag[j-1]+=1
print(sum(x==n for x in flag))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a = list(map(int,input().split()))
lis_now = set(a[1:])
like = lis_now
for i in range(n-1):
    a = list(map(int,input().split()))
    lis_new = set(a[1:])
    like = like & lis_new
    lis_now = set(lis_new)
print(len(like))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
D = {i: 0 for i in range(1, M+1)}
for i in range(N):
  L = list(map(int, input().split()))
  for j in range(1, L[0]+1):
    D[L[j]] += 1
cnt = 0
for i in D:
  if D[i] == N:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


def main():
    N, M = map(int, input().split())
    A, K = [], []
    lst = [list(map(int, input().split())) for _ in range(N)]
    for l in lst:
        A.append(l[0])
        if type(l[1:]) is list:
            K.extend(l[1:])
        else:
            K.append(l[1:])
    print(sum([1 for c in Counter(K).values() if c == len(A)]))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N_nin, M_ko = map(int, input().split())
like = []

for i in range(N_nin):
    tmp = list(map(int, input().split()))
    like.append(tmp[1:])

all_like = set(like[0])

for i in range(N_nin):
    all_like = (all_like & set(like[i])) 

print(len(all_like))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = [int(x) for x in input().split()]
lst = []
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    lst.append(tmp)

ansset = set(lst[0][1:])

for i in range(1,n):
    tmpset = set(lst[i][1:])
    ansset = (ansset & tmpset)

print(len(ansset))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=[0]*m
for _ in range(n):
    b=list(map(int,input().split()))
    for i in b[1:]:
        a[i-1]+=1
print(sum(x==n for x in a))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [list(map(int, input().split()))[1:] for _ in range(N)]
chk = {}
for a in A:
    for x in a:
        if x in chk:
            chk[x] += 1
        else:
            chk[x] = 1
print(sum([1 for k, v in chk.items() if v == N]))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
like_count = [0 for m in range(M)]
for n in range(N):
  temp = [int(i) for i in input().split()]
  for i,t in enumerate(temp):
    if i == 0:
      pass
    else:
      like_count[t-1] += 1
ans = 0
for like in like_count:
  if like == N:
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
cnt_loved=[0]*M
ans=0

for _ in range(N):
    love_list=list(map(int,input().split()))
    for a in love_list[1:]:
        cnt_loved[a-1]+=1
        
for i in range(M):
    if cnt_loved[i]==N:
        ans+=1
        
print(ans)

Submission status: Accepted

Solution code:
N, k = map(int, input().split())
L = [0] * N
K = [0] * N
for i in range(N):
    K[i], *L[i] = list(map(int, input().split()))
    if i == 0:
        ans = set(L[i])
        continue
    ans = ans & set(L[i])
print(len(ans))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
s = [input().split() for i in range(n)]
i=[]
for x in s:
    i.append(set(x[1:]))
j=i[0]
for x in range(len(i)-1):
    j=j&set(i[x+1])
print(len(j))

Submission status: Accepted

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

all_lis = []

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

ans = 0
ans_lis2 = []

for j in set(all_lis):
    ans = all_lis.count(j)
    ans_lis2.append(ans)

ans2 = 0 
for k in ans_lis2:
    if k == N:
        ans2 = ans2 + 1

print(ans2)

Submission status: Accepted

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

t1=list(map(int,input().split()))
ans=set(t1[1:])
for _ in range(n-1):
    t2=list(map(int,input().split()))
    ans &= set(t2[1:])

print(len(ans))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

    ans = set(range(1, M+1))
    for _ in range(N):
        ans &= set(map(int, input().split()[1:]))
    print(len(ans))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from collections import defaultdict

n, m = na()
a = []
for i in range(n):
    b = na()
    a.append(b)
d = defaultdict(int)

for i in range(n):
    k = a[i][0]
    for j in range(1, k + 1):
        d[a[i][j]] += 1

ans = 0
for i in d.values():
    if i == n:
        ans += 1

print(ans)

Submission status: Accepted

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

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

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

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

print(ans)