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())
suki=[0]*M 
for i in range(N):
  tmp=list(map(int, input().split()))
  for val in tmp[1:]:
    suki[val-1]+=1

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

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

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

flag = [0]*M
for i in range(N):
    for j in range(1,KA[i][0]+1):
        flag[KA[i][j]-1] += 1

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

Solution (Python):
from collections import defaultdict
N, M = list(map(int, input().split()))
K = []
A = []
for _ in range(N):
    line = list(map(int, input().split()))
    K += [line[0]]
    A += [line[1:]]

count = defaultdict(int)
for a_ in A:
    for a in a_:
        count[a] += 1

result = 0
for k, v in count.items():
    if v == N:
        result += 1
print(result)

Solution (Python):
n, m = map(int, input().split())
a = sorted([list(map(int, input().split())) for i in range(n)])
t = len(a[0]) - 1

for j in a[0][1:]:
    for k in range(1, n):
        if not j in a[k][1:]:
            t -= 1
            break

print(t)

Solution (Python):
import numpy as np

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

cnt = 0
for i in A[0]:
    flg = True
    for j in range(1,N):
        if not i in A[j]:
            flg = False
            break
    if flg:
        cnt +=1
print(cnt)

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

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

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

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

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

Solution (Python):




def main():
    from collections import Counter
    from itertools import chain
    N, M = list(map(int, input().split()))
    A = [list(map(int, input().split()))[1:] for _ in range(N)]
    c = Counter(chain(*A))
    print(len([v for v in c.values() if v >= N]))
    

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

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

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

Solution (Python):
def check(A):
  check_result = []
  for i in range(1, len(A)):
    check_result.append(list(set(A[i-1])&set(A[i])))
  if len(check_result) != len(A):
    return check_result
  return False

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
for i in range(len(A)):
  A[i].pop(0)
while True:
  check_result = check(A)
  if check_result:
    A = check_result
  else:
    if not A[0]:
      print(0)
      break
    else:
      print(len(A[0]))
      break

Solution (Python):
def check(A):
  check_result = []
  for i in range(1, len(A)):
    check_result.append(list(set(A[i-1])&set(A[i])))
  if len(check_result) != len(A):
    return check_result
  return False

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
result = []
for i in range(len(A)):
  A[i].pop(0)
while True:
  check_result = check(A)
  if check_result:
    A = check_result
  else:
    if not A[0]:
      print(0)
      break
    else:
      print(len(A[0]))
      break

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

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

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

for j in range(1,31):
	d=b.count(j)
	if d==n:
		c+=1
print(c)

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

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

K = [0]*N

A = [[] for i in range(N)]

Dict ={}

for i in range(N):
    temp = list(map(int,input().split()))
    K[i] = temp[0]
    A[i] = temp[1:]
    
for i in range(M):
    Dict[i+1]=0
    
cnt = 0


for i in range(N):
    
    for j in A[i]:
        Dict[j]+=1
        
        
for i in Dict.keys():
  
    if Dict[i] >=N:
        cnt+=1
        
print(cnt)

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

matrix = [[ False for _ in range(n)] for _ in range(m)]



for person_id in range(n):
    person = people[person_id]
    for konomi_num in person[1:]:
        matrix[konomi_num-1][person_id] = True
ans = 0
for food in range(m):
    if all(matrix[food]):
        ans += 1
print(ans)

Solution (Python):
N, M = map(int, input().split())
L = set(range(1,M+1,1))
suki = [1]*M
for i in range(N):
  indata = list(map(int, input().split()))
  K = set(indata[1:])
  Kbar = L-K
  for j in Kbar:
    suki[j-1]=0

ans = sum(suki)
print(ans)

Solution (Python):
N, _ = map(int, input().split())
KA = [list(map(int, input().split())) for _ in range(N)]
ans = set()
for i, ka in enumerate(KA):
  a = set(ka[1:])
  if not i:
    ans = a
  else:
    ans = ans & a
    
print(len(ans))

Solution (Python):
n, m = map(int, input().split())
ans = [0 for _ in range(m+1)]
for i in range(n):
    ll = list(map(int, input().split()))
    for l in ll[1:]:
        ans[l] += 1
count = 0
for i in ans:
    if i == n:
        count += 1
    else:
        pass
print(count)

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

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

print(ans.count(n))

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

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

Solution (Python):
def f11():
    N, M=map(int, input().split())
    item=[0 for i in range(M)]
    for i in range(N):
        A = [int(j) for j in input().split()]
        for j in range(A[0]):
            item[A[j+1]-1] += 1
    print(sum([1 if item[i]==N else 0 for i in range(M)]))

def main():
    f11()

main()

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

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

for i in apple:
    i.pop(0)
orange = []
for i in apple:
    for j in i:
        orange.append(j)
cat = 0
for i in range(m):
    if orange.count(i + 1) == n:
        cat += 1
    else:
        pass
print(cat)

Solution (Python):

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

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

print(len(foods))

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

for i in range(0,n):
  a[i] = input().split()
  k[i] = a[i][0]
  del a[i][0]
c = [0]*m

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

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

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

counter = 0
for j in range(1,M+1):
    if A.count(j) == N:
        counter += 1

print(counter)

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

Solution (Python):

def inp():
    return(int(input()))



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



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


N, M = invr()
K = []
for i in range(N):

    temp = inlist()
    temp = temp[1:]
    K.append(set(temp))
res = K[0]
for i in range(1, N):
    res = res.intersection(K[i])
print(len(res))

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

s = list(map(int, input().split()))
s.pop(0)

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

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

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

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

print(a.count(n))

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

ans = 0
for li in like:
    if li == n:
        ans += 1
print(ans)

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

count = [0] * M
for i in range(N):
    for j in range(len(A[i])):
        count[A[i][j]-1] += 1
print(len([i for i, x in enumerate(count) if x == N]))

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

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

ans = 0
for li in like:
    if li == n:
        ans += 1
print(ans)

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

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

A = list(map(int,input().split()))
A.pop(0)

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

print(len(A))

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

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

ka=[]
cnt=[0]*m
for i in range(n):
    ka.append([int(x) for x in input().split()])
for i in range(n):
    for j in range(1,ka[i][0]+1):
        cnt[ka[i][j]-1]+=1
print(cnt.count(n))

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())
K, A = [], []
for i in range(N):
    k, *a = list(map(int, input().split()))
    K.append(k)
    A.append(a)

like = [0]*M

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

print(like.count(N))

Solution (Python):
import sys

N, M = map(int, input().split())
A = [list(map(int, sys.stdin.readline().rsplit()))[1:] for _ in range(N)]
S = [0] * M

for i in range(N):
    for a in A[i]:
        S[a - 1] += 1

res = 0
for s in S:
    if s == N:
        res += 1
print(res)

Solution (Python):

N, M = map(int, input().split())
for i in range(N):
    if i == 0:
        K = list(map(int, input().split()))
        K = set(K[1:])
    else:
        A = list(map(int, input().split()))
        A = set(A[1:])
        K = K & A
print(len(K))

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

Solution (Python):
import itertools
import math
import fractions
import functools
import copy
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:])

ans = [0]*(m+1)

for i in range(n):
    for j in range(len(a[i])):
        ans[a[i][j]] +=1

print(ans.count(n))

Solution (Python):
from collections import deque
n, m = map(int, input().split())
a = [0]*m
for _ in range(n):
    A = deque(map(int, input().split()))
    k = A.popleft()
    if _ == 0:
        S = set(A)
    else:
        S = S & set(A)
print(len(S))

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

Solution (Python):
from collections import deque
n,m = map(int,input().split())
for i in range(n):
    A = deque(map(int,input().split()))
    k = A.popleft()
    if i == 0:
        S = set(A)
    else:
        S = S & set(A)

print(len(S))

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

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

ans = [0]*m

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

    for i in a[1:]:
        ans[i-1] += 1

cnt = 0

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

print(cnt)

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache






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






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count





N,M = inputIL()
data = inputILL(N)

s = set(i+1 for i in range(M))
for item in data:
  s &= set(item[1:])



print(len(s))

Solution (Python):




import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())
    cnt=[0]*100
    for i in range(n):
        arr=list(map(int, readline().rstrip().split()))
        for j in range(1,len(arr)):
            cnt[arr[j]]+=1
    ans=0
    for c in cnt:
        if c==n:
            ans+=1
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    food = {i: 0 for i in range(1, M + 1)}
    for _ in range(N):
        arr = list(map(int, input().split()))
        for i in range(1, arr[0] + 1):
            food[arr[i]] += 1
    ans = 0
    for key in food:
        if food[key] == N: ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict

n, m = list(map(int, input().split()))
loved_food_list = [list(map(int, input().split())) for _ in range(n)]

food_dict = defaultdict(int)

for loved_foods in loved_food_list:
    for food in loved_foods[1:]:
        food_dict[food] += 1

ans = 0
for food, num in food_dict.items():
    if num == n:
        ans += 1

print(ans)

Solution (Python):
n,m=map(int,input().split())
ls=[]
count,cnt=0,0
a=0

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

Solution (Python):
import math
import copy

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

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):
import sys
import math
import bisect

def main():
    n, m = map(int, input().split())
    A = [0] * m
    for i in range(n):
        B = list(map(int, input().split()))[1:]
        for b in B:
            A[b-1] += 1
    ans = 0
    for a in A:
        if a == n:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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())
List = []
for i in range(M):
  List.append(0)
for k in range(N):
  tmp = list(map(int,input().split()))
  for n in range(tmp[0]):
    tmp2 = tmp[n+1]
    List[tmp2-1] += 1
print(str(List.count(N)))

Solution (Python):
from collections import defaultdict

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

memo = defaultdict(int)

for n in range(N):
    _, *tmp = list(map(int, input().split()))
    for t in tmp:
        memo[t] += 1

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

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    liked = set(range(1, m+1))
    for _ in range(n):
        L = lmi()
        liked = liked.intersection(L[1:])
        
    print(len(list(liked)))




if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    f = set(range(1,M+1))
    for _ in range(N):
        a = set(list(map(int, input().split()))[1:])
        f.intersection_update(a)
    print(len(f))

if __name__ == '__main__':
    main()

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    ans = 0
    N, M = map(int, input().split())
    f = set(range(1,M+1))
    for _ in range(N):
        a = set(list(map(int, input().split()))[1:])
        f.intersection_update(a)
    print(len(f))

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import collections as c

input = sys.stdin.readline

def main():
    ans = 0
    N, M = map(int, input().split())
    a = []
    for _ in range(N):
        a += list(map(int, input().split()))[1:]
    co = c.Counter(a)
    for k, v in co.items():
        if v == N:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


n, m = Is()
KA = LIR(n)
A = []
for i in range(n):
    A.append(set(KA[i][1:]))
ans = 0
for i in range(1, m+1):
    for j in range(n):
        if i not in A[j]:
            break
    else:
        ans += 1
print(ans)

Solution (Python):
n,m = map(int,input().split())
dum = list(map(int,input().split()))
ans = dum[1:dum[0]+1]

dum = []
for i in range(n-1):
    li = list(map(int,input().split()))
    for j in range(li[0]):
        if ans.count(li[j+1]) == 1:
            dum.append(li[j+1])
    ans = dum
    dum = []
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 range(1, a[0] + 1):
        l[a[j] - 1] += 1
c = 0
for i in range(m):
    if l[i] == n:
        c += 1
print(c)

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

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

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

for i in range(n):
    for j in range(len(list_0[i])):
        kei[list_0[i][j]-1]+=1

c=0
for i in range(len(kei)):
    if kei[i]==n:
        c+=1
print(c)

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

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

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

print(d.count(N))

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

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

print(d.count(N))

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

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

Solution (Python):
N,M = map(int,input().split())
E = []
for i in range(N):
  S = list(map(int,input().split()))
  S.remove(S[0])
  L = list(set(S))
  
  E.extend(L)
p = 0
for j in range (M):
  if E.count(j+1) == N:
    p += 1
print(p)

Solution (Python):
import collections

N, M = map(int, input().split())
x = []
for n in range(N):
  l = list(set(list(map(int, input().split()))[1:]))
  
  x.extend(l)
  
c = collections.Counter(x)

ans = 0
for k in c.keys():
  if c[k] == N:
    ans += 1
print(ans)

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

print(ans.count(n))

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

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    cnt = [0] * (M+1)
    for _ in range(N):
        info = list(map(int, input().split()))
        for a in info[1:]:
            cnt[a] += 1
    ans = 0
    for m in range(M+1):
        if cnt[m] == N:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
hoge_list = [list(map(int,input().split())) 
             for nesya in range(n)]
f =[0]*m
for hoge in hoge_list:
  for i in range(len(hoge)-1):
    s = i + 1
    f[(hoge[s]-1)] += 1
ans = 0
for num in f:
  if num == n:
    ans += 1
print(ans)

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

counter = [0]*M

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

print(counter.count(N))

Solution (Python):
n,m=map(int,input().split())
ans=set()
b=set(range(1,m+1))

ans=ans.union(b)
for n in range(n):
  
  s=list(map(int,input().split()))
  ex=b - set(s[1:])
  ans=ans-ex
print(len(ans))

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

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))


def resolve():
    N,M=pin()
    ans=set(range(1,M+1))
    for i in range(N):
          k,*a=pin()
          A=set(a)
          ans=ans&A
    print(len(ans))

resolve()

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

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

for k in K:
    for like in k[1:]:
        likes[int(like)-1] += 1

print(likes.count(N))

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

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

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

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

ans = sum([c == n for c in check])
print(ans)

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

check = [0]*m

for i in range(n):
  for a_i in tuple(map(int,input().split()))[1:]:
    check[a_i-1]+=1
    
print(check.count(n))

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

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

Solution (Python):
from collections import defaultdict

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

ans = 0
for _, v in d.items():
    if v == N:
        ans += 1

print(ans)

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

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

Solution (Python):
import sys
import math
n, m = map(int, input().split())
li = [0] * m
for i in range(n):
    tmp = list(map(int, input().split()))
    for j in range(len(tmp)):
        if j == 0:
            continue
        li[tmp[j] - 1] += 1
cnt = 0
for i in li:
    if (i == n):
        cnt += 1
print(cnt)

Solution (Python):


from functools import reduce


def main():
    N, M = [int(x) for x in input().split()]
    A = [[int(x) for x in input().split()[1:]] for _ in range(N)]
    print(len(reduce(lambda a, b: a & b, map(lambda a: set(a), A))))


if __name__ == '__main__':
    main()