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())
d = [0] * m

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

c = 0
for num in d:
    if num == n:
        c += 1
print(c)

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

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

c = 0
for num in d:
    if num == n:
        c += 1
print(c)

Solution (Python):
N,M = map(int,input().split())
B = set(m for m in range(1,1+M))

for n in range(N):
  A = list(map(int,input().split()))
  B&=set(A[1:])

print(len(B))

Solution (Python):









import sys
input = sys.stdin.readline

N, M = map(int, input().split())
LikeL = []
for i in range(N):
    temp = list(map(int, input().split()))
    temp.pop(0)
    LikeL.append(temp)

ans = 0
for Mi in range(M):
    all = True
    for i in range(N):
        if not(Mi+1 in LikeL[i]):
            all = False
            break
    if all:
        ans += 1
print(ans)

Solution (Python):
N, M = map(int, input().split())
A = []
for _ in range(N):
    s = list(map(int, input().split()))
    k = s[0]
    A.append(s[1:])

foods = [0] * M
for row in A:
    for a in row:
        foods[a-1] += 1
count = 0
for f in foods:
    if f == N:
        count += 1
print(count)

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

ans = [i for i in range(1,M+1,1)]
for i in range(0,N,1):
    ans = list(set(ans) & set(A[i]))
print(len(ans))

Solution (Python):

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

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

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

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

for i in range(n):
    t=[int(i) for i in input().split()]
    t=set(t[1:])
    s=s&t
print(len(s))

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

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

count = 0
for num in love_count:
    if num == N:
        count += 1

print(count)

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

resolve()

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

s = set([])
for i in range(1,31):
    s.add(i)

for _ in range(n):
    _,*a = list(map(int, input().split()))
    s &= set(a)

print(len(s))

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

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

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

D = [0]*M

for i in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    for j in A:
        D[j-1] += 1

print(D.count(N))

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

ans = [0 for i in range(M)]
for i in range(N):
    KM = list(map(int, input().split()))
    for j in range(1, len(KM)):
        ans[KM[j]-1] += 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()))
del a[0]
if n != 1:
  for i in range(n-1):
    b = list(map(int, input().split()))
    del b[0]
    a = a+b
    a = [x for x in set(a) if a.count(x) > 1]
print(len(a))

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

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

A = np.zeros((N,M))
for i in range(N):
    a = list(map(int, input().split()))
    a = a[1:]
    A[i, 0:len(a)] = a

for i in range(N):
    a = A[i]
    a = a[(a != 0) & (a <= M)]
    if i == 0:
        s = set(list(a))
    else:
        _s = set(list(a))
        s &= _s

print(len(s))

Solution (Python):
def main():
    n,m=map(int,input().split())
    k = [list(map(int,input().split())) for _ in range(n)]
    f = [0] * m
    for i in k:
        for j in i[1:]:
            f[j-1] += 1
    print(f.count(n))
    
if __name__ == "__main__":
    main()

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


if __name__ == '__main__':
    solve()

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

Solution (Python):
N, M, *_ = map(int, open(0).read().split())

A = []
K_i = 0
for i in range(N):
    K = _[K_i]
    A.append(_[K_i+1 :  K_i+1+K])
    K_i += K + 1
    
ans = 0

for m in range(1, M+1):
    for k, a_i in enumerate(A, start=1):
        if m not in a_i:
            break
        if k == len(A):
            ans += 1

print(ans)

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

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

print(array.count(n))

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

ans = 0
for i in range(1,31):
    if b.count(i) == n:
        ans += 1
print(ans)

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,m = i2()
ls = []
for _ in range(n):
	a = intl()
	a = a[1:]
	ls.append(a)

for i in range(n-1):
	tmp = []
	for j in ls[i]:
		for k in ls[i+1]:
			if j == k:
				tmp.append(j)
	ls[i+1] = tmp

print( len(ls[-1]) )

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

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

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

for j in range(N):
    lis = list(map(int, input().split()))
    count = lis[0]
    answer = lis[1:]
    for k in answer:
        dic[k] += 1

num = [x for x in dic.values() if x == N]
print(len(num))

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

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

info = [input().split() for i in range(n)]
achi = []
for i in range(m):
    achi.append(0)



for i in range(n):
    for j in range(int(info[i][0])):
        num = int(info[i][j+1])
        achi[num-1] += 1


print(achi.count(n))

Solution (Python):
from collections import Counter
n, m = map(int, input().split())
l = []
for _ in range(n):
    k, *a = map(int, input().split())
    l += a
c = Counter(l)

cnt = 0
for val in c.values():
  if val == n:
    cnt += 1
print(cnt)

Solution (Python):
N,M = map(int,input().split())
K = []
sum = 0
if N==1:
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
  print(len(K))
  exit()
for i in range(N):
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
for T in range(1,len(K)+1):
  B=K.count(T)
  if B == N:
    sum+=1
print(sum)

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




d = {str(i):0 for i in range(1, m + 1)}


for _ in range(n):
    l = input().split()
    k = l[0]
    a = l[1:]
    
    
    
    
    for aa in a:
        d[aa] += 1
        


count = 0
for key, value in d.items():
    if value == n:
        count += 1
        
print(count)

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

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

Solution (Python):
N, M = map(int, input().split())
K_A = [list(map(int, input().split())) for _ in range(N)]
candidate = {i for i in range(1, M + 1)}
for line in K_A:
    candidate = candidate & set(line[1:])
print(len(candidate))

Solution (Python):
n,m=map(int,input().split())
x=[]
sum=0
for i in range(n):
  s=list(map(int,input().split()))
  s.pop(0)
  x+=s
for j in range(1,m+1):
  if x.count(j)==n:
    sum+=1
print(sum)

Solution (Python):
def MI():
    return map(int, input().split())

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

N, M = MI()
love = [0] * M
ans = 0

for i in range(N):
    K, *A = MI()
    for a in A:
        love[a - 1] += 1
    
for l in love:
    if l == N:
        ans += 1

print(ans)

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

c = [0] * (m+1)

for i in k:
  for j,data in enumerate(i):
    if j == 0:
      continue
    else:
      c[data] += 1

ans = 0
for i in c:
  if i == n:
    ans += 1

print(ans)

Solution (Python):

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

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

Solution (Python):


import sys
from copy import deepcopy
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    sukic=[0]*(M+1)
    for i in range(N):
        A=list(map(int,input().split()))
        for j in range(A[0]):
            sukic[A[j+1]]+=1
    print(sukic.count(N))
    
if __name__=="__main__":
    main()

Solution (Python):
import itertools
n,m=map(int,input().split())
s=list(input().split() for i in range(n))
l=[]
c=0
for j in range(n):
    l.append(s[j][1:])
l=list(itertools.chain.from_iterable(l))    

for i in range(1,m+1):
    if l.count(str(i))==n:
        c+=1
print(c)

Solution (Python):






import collections as C


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







num=[0 for x in range(31)]
for i in range(N):

    K = list(map(int,input().split()))
    for j in K[1:]:
        num[j]+=1
c=0
for k in num:
    if k==N:
        c+=1
print(c)

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

if N>1:
    for _ in range(N-1):
        B=list(map(int,input().split()))
        B.pop(0)
        A=[num for num in A if num in B]

print(len(A))

Solution (Python):






from collections import deque




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

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

Solution (Python):
def resolve():
    N, M = list(map(int, input().split()))
    l = []
    ls = list(range(1, M+1))

    for i in range(N):
        l = list(map(int, input().split()))
        ls = set(l[1:]).intersection(ls)
    print(len(ls))
    return

resolve()

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

Solution (Python):
N,M=map(int,input().split())
foods=[N]*M
for i in range(N):
    A=list(map(int,input().split()))
    K=A.pop(0)
    for j in A: foods[j-1]-=1
print(foods.count(0))

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

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

Solution (Python):


N,M = map(int,input().split())
lst = [i+1 for i in range(M)]


for _ in range(N):
    tmp = list(map(int,input().split()))
    K = tmp[0]
    A = tmp[1:]
    lst = list(filter(lambda x: x in A,lst))

print(len(lst))

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

lis = []
for _ in range(n):
    lis.append(list(map(int, input().split())))
    
like =[0] * 31

for i in range(n):
    for j in lis[i][1:]:
        like[j] += 1
        
cnt = 0
for k in like:
    if k == n:
        cnt += 1

print(cnt)

Solution (Python):
def actual(N, M, K, A):
    
    s = set(A[0])

    for a in A[1:]:
        s &= set(a)

    return len(s)


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

K = []
A = []

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

print(actual(N, M, K, A))

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

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

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

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

print(ans)

Solution (Python):
import math
def ip():return int(input())
def inp():return map(int,input().split())
def inpstr():return map(str,input().split())
def linp():return list(map(int,input().split()))
def linpstr():return list(map(str,input().split()))

n,m=inp()
l=[0]*m
for _ in range(n):
    a=linp()
    for i in range(1,a[0]+1):
        l[a[i]-1]+=1

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

Solution (Python):

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

result = []
for i in range(1,m+1):
    flg = True
    for j in anke:
        if i not in j:
            flg = False
            break
    if flg:
        result.append(i)
        

print(len(result))

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

for i in range(N):
    KA = list(map(int, input().split()))
    for a in KA[1:]:
        B[a] += 1
count = 0
for b in B:
    if b == N:
        count += 1
print(count)

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

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

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

ans = 0
for j in range(1,m+1):
  if all(j in A[i] for i in range(len(A))) == True:
    ans += 1

print(ans)

Solution (Python):
import math
from collections import deque
from collections import defaultdict


def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	
	ans = data[:]
	return ans

n,m = readInts()
data = []
for i in range(n):
	data.append(readInts()[1:])

d = defaultdict(int)

for i in data:
	for j in i:
		d[j]+=1

ans = 0
for i in d:
	if d[i]==n:
		ans+=1

print(ans)

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

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

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

Solution (Python):
if __name__ == '__main__':
    n, m = map(int, input().split())
    likeList =[0]*m
    for i in range(n):
        a = [int(i) for i in input().split()]
        for j in range(1,a[0]+1):
            likeList[a[j]-1]+=1


    count =0
    for i in likeList:
        if n == i:
            count+=1
    print(count)

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

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

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

for i in range(N):
    line = list(map(int, input().split()))[1:]
    for j in line:
        cnt[j-1] += 1

ans = sum([1 if i == N else 0 for i in cnt])
print(ans)

Solution (Python):
n,m=map(int,input().split())
a=[]
k=[]
while True:
    try:
        dk,*d=list(map(int,input().split()))
        a.append(d)
        k.append(dk)
    except:
        break;
ans=set(a[0])
for i in range(1,n):
  ans=ans&set(a[i])

print(len(ans))

Solution (Python):
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal



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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



N,M=MI()
KA=LLI(N)
like=[0]*M

for ka in KA:
    i = 0
    for a in ka:
        if i == 0:
            i += 1
            continue
        like[a-1] += 1

cnt = 0
for l in like:
    if l == N:
        cnt+=1
print(cnt)

Solution (Python):





N, M = map(int, input().split())
s = set(range(1, M+1))

for _ in range(N):
    k, *a = map(int, input().split())
    s&=set(a)
print(len(s))

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

dic = {}

for i in range(N):
  for j in range(len(KA[i])-1):
    if KA[i][1+j] not in dic.keys():
      dic[KA[i][1+j]] = 1
    else:
      dic[KA[i][1+j]] += 1
      
ans = 0

for i in dic:
  if dic[i] == N:
    ans += 1
    
print(ans)

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

ans = set([i + 1 for i in range(M)])
for _ in range(N):
    T = input().split()
    A = set([int(i) for i in T[1:]])
    ans = ans & A
print(len(ans))

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

KA = list(map(int, input().split()))
like = set(KA[1:])
for i in range(1, N):
    KA = list(map(int, input().split()))
    A = KA[1:]
    like = like & set(A)

print(len(like))

Solution (Python):


k, m = list(map(int, input().split()))


set_ = set(range(1, m+1))


for i in range(k):
    _, *a = list(map(int, input().split()))
    set_ = set_ & set(a)


print(len(set_))

Solution (Python):
n, m = map(int, input().split())
K = []
A = []
for i in range(n):
    L = list(map(int, input().split()))
    K.append(L[0])
    A.append(L[1:])

Aall = []
for e in A:
    Aall += e

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

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

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

print(foods.count(n))

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

b = []

for i in range(n):
    for j in range(1,l[i][0]+1):
        b.append(l[i][j])

ans = 0
for k in range(1,m+1):
    cnt = b.count(k)
    if cnt == n:
        ans += 1

print(ans)

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

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


ans_s = 0
for a in ans:
    if a == n:
        ans_s += 1

print(ans_s)

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    cnt = set(range(1, M+1))
    for _ in range(N):
        K, *A = map(int, input().split())
        cnt.intersection_update(set(A))
    ans = len(cnt)
    print(ans)

if __name__ == "__main__":
    main()

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

S = [0]*M

for j in range (N):
  for k in range(1, L[j][0]+1):
    S[L[j][k]-1] += 1
    
print(S.count(N))

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

Solution (Python):
def resolve():
    from collections import defaultdict
    N, M = [int(i) for i in input().split()]
    kaa = [list(map(int, input().split())) for _ in range(N)]
    ans = defaultdict(int)
    for k, *a in kaa:
        for A in a:
            ans[A] += 1
    print(list(ans.values()).count(N))


resolve()

Solution (Python):
n,m=map(int,input().split())
k=[]
c=list(range(1,m+1))
for i in range(n):
    a=list(map(int,input().split()))
    a.pop(0)
    k.append(a)
for i in range(1,m+1):
    cnt=0
    for j in range(n):
        if k[j].count(i)>0:
            cnt+=1
    if cnt!=n:
        c.remove(i)
print(len(c))

Solution (Python):
n, m = input().split(" ")
n = int(n)
m = int(m)
k = []
for i in range(n):
    k.append([])
    tmp = input().split(" ")
    for j in range(1, len(tmp)):
        k[i].append(int(tmp[j]))

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

for i in k:
    for j in i:
        dict[j] += 1

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

print(cnt)

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

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

Solution (Python):
n, m = map(int, input().split())
ans = None
for i in range(n):
    aa = tuple(map(int, input().split()))
    aa = aa[1:]
    if ans is None:
        ans = set(aa)
    else:
        ans = ans & set(aa)
print(len(ans))

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

cnt = [0] * M



for j in range(N):
  for k in range(1, L[j][0]+1):
    cnt[L[j][k]-1]+= 1


print(cnt.count(N))

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

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

Solution (Python):
import sys

input = sys.stdin.readline


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

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
n,m=map(int,input().split())
ans_list=list(input().split())[1:]
for i in range(n-1):
  l=len(ans_list)
  ans_list2=ans_list
  ans_list=[]
  keep=input().split()[1:]
  for j in range(l):
    if ans_list2[j] in keep:
      ans_list.append(ans_list2[j])
print(len(ans_list))

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

foods =set([ i+1 for i in range(m)])


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

    foods = foods&fav

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

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

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

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

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

a = []
b = list((0 for i in range(m)))

for i in range(n):
    a.append(list(map(int, input().split())))
    
for a_ in a:
    k = a_[0]
    for k_ in range(k):
        b[(a_[k_ + 1]) - 1] += 1
        
ans = 0
for b_ in b:
    if b_ == n:
        ans += 1
print(ans)

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

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

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

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

B = [0]*30

for i in range(N):
	K, *A = map(int, input().split())
	for a in A:
		B[a-1] += 1

print(sum(c == N for c in B))

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