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())
count = 0
kind = [0 for i in range(m)]
for i in range(n):
    anketo = list(map(int, input().split()))
    for j in range(1, len(anketo)):
        kind[anketo[j]-1] += 1
for i in kind:
    if i == n:
        count += 1
print(count)

Solution (Python):
n,m = map(int, input().split())
k = [list(map(int, input().split())) for i in range(n)]
food_list = [0] * m
for i in range(n):
    for j in range(len(food_list)):
        if j+1 in k[i][1:]:
            food_list[j] += 1
        else:
            continue
cnt = 0
for i in range(len(food_list)):
    if food_list[i] == n:
        cnt += 1
    else:
        continue
print(cnt)

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

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

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):
from sys import stdin, exit
from math import factorial
input = stdin.readline
lmi = lambda: list(map(int, input().split()))
mi = lambda: map(int, input().split())
si = lambda: input().strip('\n')
ssi = lambda: input().strip('\n').split()

n, m = mi()
foods = [0 for i in range(m+1)]
for i in range(n):
    arr = lmi()
    for j in arr[1:]:
        foods[j] += 1
cnt= 0
for i in range(1, m+1):
    if foods[i] == n:
        cnt += 1
print(cnt)

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

Solution (Python):
N,M=map(int,input().split())
a=[0 for i in range(M)]
for i in range(N):
    for Aij in (list(map(int,input().split())))[1:]:
        a[Aij-1]+=1
print(len([ai for ai in a if ai==N]))

Solution (Python):
n,m=map(int,input().split())
k=[list(map(int,input().split())) for i in range(n)]
k.sort(key=lambda x: x[0])
cnt=0

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

Solution (Python):

from collections import defaultdict


def main():
    N, M = map(int, input().split())
    cnt = defaultdict(int)
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            cnt[a] += 1
    ans = sum(i == N for i in cnt.values())
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
from sys import stdin
import numpy as np

N,M = map(int,stdin.readline().strip().split())

A = np.zeros((N,M))

for i in range(N):
    inp = list(map(int,stdin.readline().strip().split()))
    for j in range(inp[0]):
        A[i,inp[j+1]-1] = 1

B = np.sum(A,axis=0)
print(np.count_nonzero(B==N))

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

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())
K = []
A = []
for _ in range(n):
  k, *a = map(int, input().split())
  K.append(k)
  A.append(a)
C = 0
for a in A[0]:
  c = 0
  for i in range(1,n):
    if A[i].count(a):
      c += 1  
  if c==n-1:
    C += 1  
print(C)

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

ans = {i+1 for i in range(m)}
for a in A:
    ans = ans & set(a[1:])

print(len(ans))

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

Solution (Python):
import numpy as np
N , M = map(int,input().split())
food_list = np.zeros(M)
for i in range(N):
    work = list(map(int,input().split()))
    work.pop(0)
    for idx in work:
        food_list[idx - 1] += 1
cnt = 0
for food in food_list:
    if food == 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())
k_list = []
a_list = []
for _ in range(n):
    k, *a = map(int, input().split())
    k_list.append(k)
    a_list.append(a)
    
ans = [0]*m
for i in range(m):
    for j in range(len(k_list)):
        if i+1 in a_list[j]:
            ans[i] += 1
if max(ans) == n:
    print(ans.count(n))
else:
    print(0)

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

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

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

Solution (Python):
n, m = map(int, input().split())
cnt = [0] * m
for _ 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=[]
ans=0
for i in range(n):
    ii=0
    for j in map(int,input().split()):
        if ii > 0:
        	a.append(j)
        ii+=1

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

Solution (Python):
N, M = map(int, input().split())
A = [[int(i) for i in input().split()] for _ in range(N)]
cnt = {}
for i in A:
    for j in i[1:]:
        if j in cnt:
            cnt[j] += 1
        else:
            cnt[j] = 1
ans = len([k for k in cnt if cnt[k] == N])
print(ans)

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

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

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

Solution (Python):
n, m = (int(x) for x in input().split())
c = [0 for _ in range(m)]
for _ in range(n):
    r = [int(x) for x in input().split()]
    for i in r[1:]:
        c[i-1] += 1
print(c.count(n)) if n in c else print(0)

Solution (Python):
import itertools

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

A = [x-1 for x in list(itertools.chain.from_iterable(A))]

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

print(ans)

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

A = []
for i in range(N):
    for j in range(1,K[i][0] + 1):
        temp = K[i][j]
        A.append(temp)
ans = 0
for i in range(1,31): 
    if A.count(i) == N:
        ans +=1
    if N == 1:
        ans = K[0][0]
print(ans)

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

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

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

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    ls = []
    for i in range(n):
        ka = list(map(int, input().rstrip('\n').split()))
        for j in range(1, ka[0] + 1):
            ls.append(ka[j])
    ls = collections.Counter(ls)
    cnt = 0
    for k, v in ls.items():
        if v == n:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()

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

food = [0] * M
ans = 0

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

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

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

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

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

ans = 0

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

Solution (Python):
N,M = map(int,input().split())
k=dict.fromkeys(range(1,31),0)
count=0
for i in range(N):
    x=list( map( int,input().split() ) )[1:]

    for j in x:

        k[j]+=1


for value,key in k.items():
    if key==N :
        count += 1

        
    
        
print(count)

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

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

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

print(ans)

Solution (Python):
N,M = map(int,input().split())
likes = [0 for _ in range(M)]
for _ in range(N):
  for food in list(map(int,input().split()))[1:]:
    likes[food-1] += 1
ans = 0
for like in likes:
  if like == N:
    ans += 1
print(ans)

Solution (Python):
n,m=map(int,input().split())
l=[]
c=0
mm=list(range(1,m+1))
for i in range(n):
    ll=list(map(int,input().split()))
    l.append(ll)
    del l[i][0]
for i in range(m):
    t=True
    for j in range(n):
        if mm[i] not in l[j]:
            t=False
    if t:
        c+=1
print(c)

Solution (Python):
n,m=map(int,input().split())
l=[]
c=0
mm=list(range(1,m+1))
for i in range(n):
    ll=list(map(int,input().split()))
    l.append(ll)
    del l[i][0]
for i in range(m):
    t=True
    for j in range(n):
        if mm[i] not in l[j]:
            t=False
    if t:
        c+=1
print(c)

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

ancket = []
list_like = []
menu = {}

for i in range(m):
  menu[i+1] = 0

for i in range(n):
  ancket = list(map(int, input().split()))
  k = ancket[0]
  list_like = ancket[1:k+1]
  for j in range(k):
      menu[list_like[j]] += 1
      
sum = 0
for i in range(m):
  if menu[i+1] == n:
    sum += 1

print(sum)

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

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

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

print(P)

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *

from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

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

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

if __name__ == '__main__':
    main()

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())
_,*ans=map(int,input().split())
for i in range(n-1):
    _,*k=map(int,input().split())
    ans=[i for i in k if i in ans]
print(len(ans))

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

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

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


def main():
    N, M = map(int, input().split())
    
    C = [0]*M
    for _ in range(N):
        A = list(map(int, input().split()))
        for i in range(1, A[0]+1):
            C[A[i]-1] += 1
    
    print(C.count(N))


if __name__ == '__main__':
    main()

Solution (Python):

std_input = open(0).readlines()
N, M = map(int, std_input[0].split())

A = [list(map(int, i.rstrip("\n").split())) for i in std_input[1:1+N]]

intersection = [i+1 for i in range(M)]

for i in A:
    intersection = set(intersection) & set(i[1:])
print(len(intersection))

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

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

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    k = [set([int(i) for i in input().split()[1:]]) for _ in range(n)]
    ans = k[0]
    for i in k[1:]:
        ans &= i
    print(len(ans))


if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
M_dict = {i:0 for i in range(1, M+1)}
for _ in range(N):
    K, *A_list = map(int, input().split())
    for k in range(K):
        M_dict[A_list[k]] += 1

ans = 0
for j in range(1, M+1):
    if M_dict[j] == N:
        ans += 1
print(ans)

Solution (Python):
n,m=[int(s) for s in input().split()]
ls=[0 for _ in range(m+1)]
for i in range(n):
  ls2=[int(s) for s in input().split()]
  for j in range(ls2[0]):
    ls[ls2[j+1]]+=1
x=0
for i in range(m+1):
  if ls[i]==n:
    x+=1
print(x)

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

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

Solution (Python):
n,m = map(int, input().split())
l = [{int(i) for i in input().split()[1:]} for i in range(n)]
cnt =l[0]
for a in l:
  cnt =cnt & a
print(len(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):
from collections import deque
import sys

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

all_like=deque(list(map(int,input().split())))
all_like.popleft()

for _ in range(n-1):
    like=deque(list(map(int,input().split())))
    k=like.popleft()
    for _ in range(len(all_like)):
        eq=0
        al=all_like[0]
        for i in range(k):
            if al==like[i]:
                eq=1
                
        if eq==1:       
            all_like.append(all_like.popleft())
        else:
            all_like.popleft()
            if len(all_like)==0:
                print(0)
                sys.exit()
                
print(len(all_like))

Solution (Python):
N,M = map(int,input().split())
K = [list(map(int,input().split()))[1:] for _ in range(N)]
t = 0
for i in range(1,M+1):
    s = 0
    for l in K:
        if i in l:
            s += 1
    if s == N:
        t += 1
print(t)

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

c = [0 for i in range(M + 1)]

for i in range(N):
    for j in range(a[i][0] + 1):
        if j == 0: continue
        c[a[i][j]] += 1

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

print(ans)

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

if n == 1:
    print(ka[0][0])
    exit()

counter = [0] * m
for x in ka:
    for a in x[1:]:
        counter[a - 1] += 1
ans = 0
for i in range(m):
    if counter[i] == n:
        ans += 1
print(ans)

Solution (Python):
n, m = map(int, input().split())
cnt = 0
like = []
frag = 1
for i in range(n):
  s = list(map(int, input().split()))
  like.append(s[1:])
for i in range(m):
  for j in range(n):
    if(not(i+1 in like[j])):
      frag = 0
      break
  if(frag == 1):
    cnt += 1
  frag = 1
print(cnt)

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

L = []
for i in range(n):
      L2 = list(map(int,input().split()))
      L += L2[1:]

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

print(ans)

Solution (Python):


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

like = [0] * m
for i in range(n):
    inpt = map(int, raw_input().split())
    for j in range(inpt[0]):
        like[inpt[j+1] - 1] += 1

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

print ans

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

like = {}

for i in range(n):
  ancket = list(map(int,input().split()))
  for j in range(1, ancket[0]+1):
    if ancket[j] in like:
      like[ancket[j]] += 1
    else:
      like[ancket[j]] =1
sum = 0

for i in range(0,m):
  if (i + 1) in like:
    if like[(i+1)] == n:
      sum += 1
  
print(sum)

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

everyone_loves = set(i for i in range(1, M+1))
for like in likes:
    everyone_loves = everyone_loves & set(like[1:])

print(len(everyone_loves))

Solution (Python):
N,M=map(int,input().split())
arr=[0]*M
for _ in range(N):
    l=list(map(int,input().split()))
    for i in range(l[0]):
        arr[l[i+1]-1]+=1
print(sum(map(lambda x: x==N, arr)))

Solution (Python):
n,m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
S =[]
ans = 0
for i in range(0,n):
    for j in range(1,s[i][0]+1):
        S.append(s[i][j])

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

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

for i in range(n):
  k=[int(x) for x in input().split()]
  for i in range(1,k[0]+1):
    l[k[i]-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())

a = []
for _ in range(n):
    _, *fav = map(int, input().split())
    a.append(set(fav))

common_fav = a[0]
for i in range(1, n):
    common_fav = common_fav & a[i]
print(len(common_fav))

Solution (Python):
n,m = map(int,input().split())	
ka = sorted([list(map(int, input().split())) for _ in range(n)])
cnt={}
for i in range(n):
    for j in range(ka[i][0]):
        if ka[i][j+1] not in cnt:
            cnt[ka[i][j+1]]=1
        else:
            cnt[ka[i][j+1]]+=1
ans=0
for c in cnt:
    if cnt[c]==n:
        ans+=1
print(ans)

Solution (Python):
n,m=map(int,input().split())
a=[]
total=0
for i in range(n):
    k=list(input().split())
    ''.join(k)
    a.extend(k[1:len(k)])
for i in range(1,m+1):
    if a.count(str(i))==n:
        total+=1
print(total)

Solution (Python):
N, M = map(int,input().split())
foods = [0 for m in range(M)]
for n in range(N):
    A = list(map(int, input().split()))
    for a in A[1:]:
        foods[a-1]+=1
print(len([f for f in foods if f == N]))

Solution (Python):
N, M = map(int,input().split())
foods = [0 for m in range(M)]
for n in range(N):
    A = list(map(int, input().split()))
    for a in A[1:]:
        foods[a-1]+=1
foods_ans = [f for f in foods if f == N]


print(len(foods_ans))

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

tmp = {}
for src in src_all:
    for i,s in enumerate(src):
        if i != 0:
            if s in tmp:
                tmp[s] += 1
            else:
                tmp[s] = 1
count = 0
for t in tmp.values():
    if t == n:
        count +=1
print(count)

Solution (Python):
n,m = (int(i) for i in input().split())
a = [{int(i) for i in input().split()[1:]} for _ in range(n)]
ans = a[0]
for s in a:
  ans = ans & s
print(len(ans))

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

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

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

for i in range(N):
    favorite.append(list(map(int, input().split())))

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

for k in favorite:
    for l in test.keys():
        if l in k[1::]:
            test[l] += 1

        if test[l] == N:
            output += 1

print(output)

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

Solution (Python):
n, m = map(int, input().split())
ans = list(range(1, m+1))
for i in range(n):
  a = list(map(int, input().split()))
  a.pop(0)
  ans = list(filter(lambda x: x in a, ans))
print(len(ans))

Solution (Python):
N, M = map(int, input().split())
ans = [0]*M
for i in range(N):
    A = list(map(int, input().split()))
    for j in range(1, len(A)):
        ans[A[j]-1] += 1
cnt = 0
for i in ans:
    if i == 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())

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


print(sum([1 for k in pref if k == 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())
    a = set(a)
    s &= a
print(len(s))

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

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

print(sum([1 for k in l if k == 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())
food = [0] * M
ans = 0
for _ in range(N):
	array = list(map(int, input().split()))
	for i in range(1,array[0]+1):
		food[array[i]-1] += 1
for i in food:
	if i == N:
		ans += 1
print(ans)

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

all_list = [i for i in range(1, M+1)]
res_set = set()

for i in range(len(KA)):
    diff_set = set(all_list) ^ set(KA[i][1:])
    res_set = res_set | diff_set

print(M - len(res_set))

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

for i in range(N):
  temp=list(map(int, input().split()))
  k=len(temp)
  for j in range(1, k):
    a[temp[j]]+=1
    
counter=0
for i in range(1, M+1):
  if a[i]==N:
    counter+=1
    
print(counter)

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

res = set(KA[0][1:])
for a in KA[1:]:
    res = res & set(a[1:])
print(len(res))

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

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

dict = {}
for i in range(N):
    for j in range(1,len(K[i])):
        if K[i][j] in dict:
            dict[K[i][j]] += 1
        else:
            dict[K[i][j]] = 1

cnt = 0
for v in dict.values():
    if v == N:
        cnt += 1
print(cnt)

Solution (Python):
import collections

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

res_list = []

for _ in range(n):
  temp_list = list(map(int, input().split()))
  for i in range(1, temp_list[0]+1):
    res_list.append(temp_list[i])


print(list(collections.Counter(res_list).values()).count(n))

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

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

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

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

count=0
for k in range(1,M+1):
    if b.count(k) == N:
        count +=1
        
print(count)

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

Solution (Python):
N,M=map(int,input().split())
List=[]
for i in range(N):
  List.append(list(map(int,input().split())))
List_K=[]
List_A=[]
for j in range(N):
  List_K.append(List[j][0])
  List_A.append(List[j][1:])
count=0
for k in range(M+1):
  count1=0
  for l in range(N):
    if k in List_A[l]:
      count1+=1
  if count1==N:
    count+=1
print(count)

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

l = [[int(i) for i in input().split()] for _ in range(n)]

food_set = {i for i in range(1,m+1)}
for i in l:
    food_set = food_set & set(i[1:])
    
print(len(food_set))

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

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

if __name__=='__main__':
    main()

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

if __name__=='__main__':
    main()

Solution (Python):

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

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

food = list(range(1, m+1))

for _ in range(n):
    A = list(map(int, input().split()))
    A.pop(0)
    for i in range(1, 31):
        if not i in A and i in food:
            food.remove(i)

print(len(food))

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

Solution (Python):


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

ka = []

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


common = [i for i in range(1,m+1)]


for i in range(n):
    
    temp = common + ka[i][1:]
    common = [x for x in set(temp) if temp.count(x) > 1]

print(len(common))

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


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

Solution (Python):
N,M=map(int,input().split())
set_list=[]
sets=set()
for i in range(N):
    s=input().split()
    s.pop(0)
    set_list.append(set(s))
for set in set_list:
    if len(sets)==0:
        sets=set
    else:
        sets=sets.intersection(set)
print(len(sets))

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

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

print(num)

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

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

Solution (Python):
if __name__ == '__main__':
    N, M = map(int, input().split())
    like = [0]*(M+1)
    
    for i in range(N):
        row = list(map(int, input().split()))
        for j in range(1,len(row)):
            like[row[j]] += 1
    count = 0
    for l in like:
        if l == N:
            count += 1
    print(count)

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

like = set()

K, *A = map(int, input().split())
like = set(A)

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

print(len(like))

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

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

Solution (Python):

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

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
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())
like = [0]*M
for i in range(N):
  k,*A = map(int,input().split())
  for j in A:
    like[j-1] += 1
print(like.count(N))