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())

k_lst = []
a_lst = []
for _ in range(n):
    lst = list(map(int,input().split()))
    k_lst.append(lst[0])
    a_lst.append(lst[1:])

temp = a_lst[0]

for i in range(1,n):
    lstwa = temp + a_lst[i]
    tyofuku = [x for x in set(lstwa) if lstwa.count(x) > 1]
    temp = tyofuku

print(len(temp))

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

l = []
for i in range(N):
    for j in ka[i][1:]:
        l.append(j)

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

print(ans)

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

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

ans = 0

for i in range(1, M + 1):
    for K in A:
        if K.count(i) == 0:
            break
    else:
        ans += 1

print(ans)

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

Solution (Python):
from collections import Counter
N, M = map(int, input().split())
c = Counter()
for i in range(N):
    K, *A = list(map(int, input().split()))
    c.update(A)
r = 0
for k, v in c.items():
    if v == N:
        r += 1
print(r)

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

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


menu =[0]*m 
for i in range(n):
    k,*a = map(int,input().split())
    for j in range(k):
        menu[a[j]-1] += 1

print(menu.count(n))

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

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

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

Solution (Python):
N, M = list(map(lambda a: int(a), input().split(" ")))
P = [(i + 1) for i in range(M)]
s = []
for j in range(N):
  A = list(map(lambda x: int(x), input().split(" ")))
  s.append(A[1:])
  
for k in range(len(s)):
  P = list(set(P) & set(s[k]))


print(len(P))

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

kyoutu = []

for i in range(1,31):
    kyoutu.append(i)

for _ in range(n):
    A = inintl()
    t = A[1:]
    kyoutu = set(kyoutu) & set(t)

print(len(kyoutu))

Solution (Python):
N,M = map(int, input().split())
an_li = list(map(int, input().split()))
an_li.remove(an_li[0])
for i in range(N-1):
    flag = False
    r = []
    li = list(map(int, input().split()))
    li.remove(li[0])
    for t in an_li:
        if t in li:
            a = 1
        else:
            r.append(t)
            flag = True
    if flag:
        for w in r:
            an_li.remove(w)
print(len(an_li))

Solution (Python):
N, M = map(int, input().split())
s = set()
for i in range(N):
    K, *A = map(int, input().split())
    if i == 0:
        s = set(A)
    else:
        t = set(A)
        s = s.intersection(t)
print(len(s))

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

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

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

ans = [0]*M
for i in range(N):
    K,*A = [int(j) for j in input().split()]
    for k in range(K):
        ans[A[k]-1] += 1

print(ans.count(N))

Solution (Python):
n, m = [int(x) for x in input().split()]
a = {i : 0 for i in range(1, m+1)}

for _ in range(n):
  k, *likes = [int(x) for x in input().split()]
  for l in likes:
    a[l] += 1

result = len(list(filter(lambda x : x == n, a.values())))
print(result)

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m = nm()
    cnt = [0] * m
    for i in range(n):
        k, *A = nm()
        for a in A:
            cnt[a - 1] += 1
    print(cnt.count(n))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()

    X = [0]*(M+1)
    for i in range(N):
        Y = list(mi())
        for a in Y[1:]:
            X[a] += 1
    
    ans = 0
    for x in X:
        if x == N:
            ans += 1
    
    print(ans)
            
        



if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
z = [0]*(m+1)

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

cnt = 0

for i in z:
    if i == 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())
counter_map = [0] * (m + 1)

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

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

print(res)

Solution (Python):
import collections

N, M = map(int, input().split())
koubutu = []
for _ in range(N):
    ka = list(map(int, input().split()))
    koubutu.extend(ka[1:])
print(list(collections.Counter(koubutu).values()).count(N))

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

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

print(like.count(n))

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

res = [0] * (M + 1)

for _ in range(N):
    A = list(map(int, input().split()))
    K = A.pop(0)
    for a in A:
        res[a] += 1

ans = 0

for r in res:
    if r == N:
        ans += 1

print(ans)

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

print(len(l))

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

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

for i in range(N):
    x = KA[i][1:]
    for j in x:
        food[j - 1] += 1

print(food.count(N))

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M = map(int, input().split())
suki = [0] * M
for _ in range(N):
    K, *A = map(int, input().split())
    for a in A:
        suki[a-1] += 1

ans = len(list(filter(lambda x: x == N, suki)))
print(ans)

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

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

print(len(ansset))

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

food_dict = {}

for i in range(num):
    l = list(map(int,input().split()))
    for j in range(1,l[0]+1):
            food_dict.setdefault(l[j],0)
            food_dict[l[j]] += 1

ans = 0

for name, likes in food_dict.items():
    if likes == num:
        ans += 1

print(ans)

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

food_dict = {}

for i in range(num):
    l = list(map(int,input().split()))
    for j in range(1,l[0]+1):
            food_dict.setdefault(l[j],0)
            food_dict[l[j]] += 1

ans = 0

for name, likes in food_dict.items():
    if likes == num:
        ans += 1

print(ans)

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

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

Solution (Python):
n, m = map(int, input().split())
cnt = [0] * (m + 1)

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

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

print(ans)

Solution (Python):
N,M = map(int,input().split())
C = [0] * (M+1)
for i in range(N):
    K = list(map(int, input().split()))
    for k in range(len(K)):
        if k != 0:
            C[K[k]] += 1
count = 0

for c in C:
    if c == N:
        count += 1

print(count)

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

x = [0]*m

for i in range(n):
  for k in range(1,a[i][0]+1):
    x[a[i][k]-1] += 1
count = 0
for i in range(m):
  if x[i] == n:
    count += 1
print(count)

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

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

print(count)

Solution (Python):
def main():
    N, M = map(int, input().split())
    K = []
    for i in range(N):
        K.append(list(map(int, input().split())))
    l = []
    ans = 0
    for i in range(M+1):
        l.append(0)
    for i in range(N):
        for j in range(K[i][0]):
            l[K[i][j+1]] += 1
    for i in range(len(l)):
        if l[i] == N:
            ans += 1
    print(ans)
main()

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

Solution (Python):
n,m=map(int,input().split())
mist=[0 for i in range(m)]
for j in range(n):
    temp=list(map(int,input().split()))
    for s in range(1,len(temp)):
        mist[temp[s]-1]+=1

ans=sum(1 for x in mist if x==n)

print(ans)

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


print(len(ans))

Solution (Python):
from collections import Counter
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for _ in range(n)]

foods = [0]*m
for i in ka:
    for j in i[1:]:
        foods[j-1] += 1

foods = Counter(foods)
print(foods[n])

Solution (Python):
N, M = map(int,input().split())
a = []
ans = range(1,M + 1)
ans = list(ans)
for i in range(N):
    A = list(map(int,input().split()))
    K = A[0]
    A.remove(A[0])
    for j in range(1,M + 1):
        if j not in A:
            a.append(j)
for i in a:
    if i in ans:
        ans.remove(i)
print(len(ans))

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

Solution (Python):
































































def calculation(lines):
    
    
    N, M = list(map(int, lines[0].split()))
    
    
    
    
    valueses = list()
    for i in range(N):
        valueses.append(list(map(int, lines[i+1].split())))

    dic = dict()
    for values in valueses:
        for i in range(1, len(values)):
            value = values[i]
            if value not in dic.keys():
                dic[value] = 1
            else:
                dic[value] += 1

    result = 0
    for key in dic:
        if dic[key] == N:
            result += 1

    return [result]



def get_input_lines():
    line = input()
    N, M = list(map(int, line.split()))
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 4', '2 1 3', '3 1 2 3', '2 3 2']
        lines_export = [1]
    if pattern == 2:
        lines_input = ['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']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['1 30', '3 5 10 30']
        lines_export = [3]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
N,M=map(int,input().split())
ListMaster=[]
for i in range(M):
  ListMaster.append(i+1)
s =set(ListMaster)
mid = set()
List = []
for i in range(N):
  List.append(list(map(int, input().split())))
for i in range(N):
  List[i].pop(0)
for i in range(N):
  mid = set(List[i])
  s = s&mid
print(len(s))

Solution (Python):
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)

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

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

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

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

cnt = 0
for k,v in l.items():
  if v==n:
    cnt += 1
print(cnt)

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

lst = [0]*M

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

ans = lst.count(N)
print(ans)

Solution (Python):
n, m = map(int, input().split())
ka = [list(map(int, input().split())) for i in range(n)]
l = [True] * m
for i in ka:
  K = i[0]
  for j in range(m):
    if j+1 not in i[1:]:
      l[j] = False
print(l.count(True))

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

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

for i in range(n):
  l = [int(num) for num in input().split()]
  an.append(l[1:])

check = {}
for i in an:
  for j in i:
    if j not in check:
      check[j] = 1
    else :
      check[j] += 1

answer = 0
for v in check.values() :
  if v == n:
    answer +=1
      
print(answer)

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



def comp(lst1,lst2):
    ret = []
    for i in lst1:
        if i in lst2:
            ret.append(i)
    return ret
ret = list(map(int,input().split()))
ret = ret[1:]

for i in range(1,N):
    lst = list(map(int,input().split()))
    ret = comp(ret,lst[1:])
    
print(len(ret))

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

A=[]
for i in range(N):
  x = [int(i) for i in input().split()]
  A = A + x[1:]

ans = 0
from collections import Counter
for k,v in Counter(A).items():
  
  if v==N: ans += 1

print(ans)

Solution (Python):



n,m = map(int,input().split())
K_2=[]
t = 0
for i in range(n):
    A, *K =list(map(int,input().split()))
    K_2 +=K
K_3 = list(set(K_2))
for j in range(len(K_3)):
    K_4 = K_2.count(K_3[j])
    if K_4 == n:
        t +=1
print(t)

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

Solution (Python):
N, M = input().split(' ')
N = int(N)
M = int(M)
K1 = input().split(' ')
Like = [int(K1[i]) for i in range(1, len(K1))]
Like = set(Like)
for i in range(N-1):
  K = input().split(' ')
  K = [int(K[i]) for i in range(1, int(K[0])+1)]
  K = set(K)
  Like &= K
print(len(Like))

Solution (Python):
x = list(map(int, input().split()))
k = [list(map(int, input().split())) for i in range(x[0])]
f = 0
for i in k:
  i.pop(0)
  if f == 0:
    tmp = i
    f = 1
    s = i
  else:
    s = set(tmp) & set(i)
    tmp = s
print(len(s))

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m = map(int, input().split())
    foods = [0] * m
    ans = 0
    for _ in range(n):
        k = list(map(int, input().split()))
        for i in range(1, k[0]+1):
            foods[k[i]-1] += 1
    for i in range(m):
        if foods[i] == n:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().split())
L = [0]*31

for n in range(N):
  K,*A = map(int,input().split())
  for a in A:
    L[a]+=1
    
print(L.count(N))

Solution (Python):
import math
def main():
  n,m = list(map(int,input().split()))
  alist=[[]]
  for i in range(0,n):
    alist.append(list(map(int,input().split())))
  ans=set(alist[1][1:])
  for i in range(2,n+1):
    ans=ans & set(alist[i][1:])
  print(len(ans))
main()

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

for i in range(N):
  KA = list(map(int,input().split()))
  A = KA[1:]
  
  for i in range(M):
    if not (i+1) in A:
      LIKE[i] = False
      
print(LIKE.count(True))

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]

from collections import defaultdict 



N, M = mi()

d = defaultdict(int)

for _ in range(N):
    A = li()
    for i in range(1, len(A)):
        d[A[i]] += 1

ans = 0

for key, value in d.items():
    if value == N:
        ans += 1

print(ans)

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

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

for i in a:
    for j in i[1:]:
        d[j] += 1
ans = 0
for i in d.values():
    if i == n:
        ans += 1
print(ans)

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

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

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

Solution (Python):
N,M = map(int,input().split())
like = [1]
for i in range(2,M+1):
  like.append(i)
for j in range(N):
  A = list(map(int,input().split()[1:]))
  for l in range(M):
    if l+1 in A:
      continue
    else:
      if l+1 in like:
        like.remove(l+1)
print(len(like))

Solution (Python):

N,M = map(int,input().split())
a = [0 for i in range(31)]
for i in range(N):
    l = list(map(int,input().split()))
    for i in range(1,31):
        for j in l[1:]:
            if i == j:
                a[i] +=1


cou = 0
for i in a:
    if i == N:
        cou+=1
    
print(cou)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

ans = 0
for c in cnt:
    if c == n:
        ans += 1
print(ans)

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

Solution (Python):





def main():
    N, M = map(int, input().split())
    k_a = [None] * N
    for i in range(N):
        k_a[i] = list(map(int, input().split()))
    
    food = [0] * (M+1)
    for i in range(N):
        for j in range(1, k_a[i][0]+1):
            food[k_a[i][j]] += 1
    
    ans = 0
    for m in range(1, M+1):
        if food[m] == N:
            ans += 1
    
    return ans


print(main())

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

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

like_cnt = {i: 0 for i in range(1, m + 1)}
for ai in a:
    for aij in ai:
        like_cnt[aij] += 1
print(list(like_cnt.values()).count(n))

Solution (Python):
def main():
    n,m = map(int,input().split())
    a = []
    for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
    l = [0 for i in range(m)]
    for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
    ans = 0
    for i in range(m):
        if l[i] == n:
            ans += 1
    print(ans)

main()

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

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

Solution (Python):
import sys
import collections
import itertools

N,M = map(int,input().split())
array_2 = []
for I in range(N):
    array_2.append(input().split())
for I in array_2:
    del I[0]

array_2 = itertools.chain.from_iterable(array_2)
array_2 = collections.Counter(array_2)
count = 0
for I in array_2:
    if array_2[I] == N: count += 1
print(count)

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

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

Solution (Python):
N, M = list(map(int, input().split()))
B = [True] * M
for i in range(N):
    A = list(map(int, input().split()))[1:]
    _B = [False] * M
    for a in A:
        _B[a - 1] = True
    B = list(map(lambda x: x[0] and x[1], zip(B, _B)))
print(sum(filter(lambda x: x, B)))

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

Solution (Python):
N,M  = (int(X) for X in input().split())
Food = set(range(1,M+1))
for T in range(0,N):
    Food = Food.intersection(set([int(X) for X in input().split()][1:]))
print(len(Food))

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

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

Solution (Python):

(n, m), *a = [[*map(int, i.split())] for i in open(0)]
like = [0] * m
for i in a:
    for j in i[1:]:
        like[j - 1] += 1
print(sum(i == n for i in like))

Solution (Python):
(n,m), *ka = [list(map(int, s.split())) for s in open(0)]

c = [0]*(m+1)

for k, *a in ka:
    for elm in a:
        c[elm] += 1

print(c.count(n))

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
li = [0]*m
for _ in range(n):
  for i in rl()[1:]:
    li[i-1]+=1
print(sum([i==n for i in li]))

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

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

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

for ka in KA:
    ans = ans & set(ka[1:])

print(len(ans))

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

for i in range(n):
    for j in range(k[i][0]):
        l[k[i][j + 1] - 1] += 1

print(l.count(n))

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

nums = [0]*m
for i in ka:
  for j in range(1,i[0]+1):
    nums[i[j]-1] += 1
print(nums.count(n))

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

for i in range(n):
    k, *l = map(int, input().split())
    food = set(l) & food

print(len(food))

Solution (Python):
N, M = map(int,input().split())
f = []
for i in range(N):
  f.append(list(map(int,input().split())))
c = 0
for i in range(M):
  b = False
  for j in range(N):
    if not i+1 in f[j][1:]:
      b = True
      break
      
  if not b:
    c+=1
print(c)

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

S = set(i for i in 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())

favorite=[0]*(m+1)

for i in range(n):
  k_=list(map(int,input().split()))
  for j in range(1,k_[0]+1):
    
    favorite[k_[j]]+=1
    
  
print(favorite.count(n))

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

Solution (Python):
import collections
n, m = map(int, raw_input().split(' '))
cc = collections.Counter()
for _ in range(n):
	for a in map(int, raw_input().split(' '))[1:]: cc[a] += 1
count = 0
for k in cc:
  	if cc[k] == n: count +=1
print count

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

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

for i in range(n):
    for j in range(1, len(ansers[i])):
        foods[ansers[i][j]] += 1

print(foods.count(n))

Solution (Python):
n, m = [int(w) for w in input().split()]
menu = [0] * m

for i in range(n):
    _, *la = [int(w) for w in input().split()]
    for a in la:
        menu[a - 1] += 1

print(len([w for w in menu if w == n]))

Solution (Python):

import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
K =[0]*N
A=[]
for i in range(N):
    a,*b = list(map(int, input().split()))
    K[i] =a
    A.append(set(b))
ans =set(list(A[0]))
for i in A:
    ans &=i
print(len(ans))

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

X=[0]*(M+1)
for _ in range(N):
    A=list(map(int,input().split()))[1:]
    for a in A:
        X[a]+=1
print(X.count(N))

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

Solution (Python):
N, M = map(int, input().split())
K =[set(input().split()[1:]) for _ in range(N)]
T = K[0]
for k in K:
  T = T&k
print(len(T))

Solution (Python):
N,M=map(int,input().split())
Like=[0 for i in range(M)]
A=[[] for i in range(N)]
for i in range(N):
  A[i]=[int(x) for x in input().split()]
for i in range(N):
  for j in range(1,A[i][0]+1):
    Like[A[i][j]-1]=Like[A[i][j]-1]+1
print(Like.count(N))

Solution (Python):
N, M = map(int, input().split())
res = set(list(range(1, M+1)))
for _ in range(N):
    k, *a = map(int, input().split())
    res = res.intersection(a)
print(len(res))