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

cnt = [0]*M
W = [0]*N
for i in range(N):
    W[i] = list(map(int, input().split()))
    for k in range(1, W[i][0]+1):
        cnt[W[i][k]-1] += 1
ans = cnt.count(N)
print(ans)

Solution (Python):


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

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

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

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

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

base=[N]*M

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

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

for i in range(n-1):
    k = k & set(input()[2:].split())
    
print(len(k))

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

    num_list = []
    for _ in range(n): 
        num_list.append(list(map(int,input().split())))

    ans = 0

    ans_list = [0] * m

    for i in range(n):
        for j in range(num_list[i][0]):
            ans_list[num_list[i][j+1]-1] += 1
        
    for i in range(m):
        if n == ans_list[i]:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):
n,m = map(int,input().split())
ans = 0
que = []
for i in range(n):
    a = list(map(int,input().split()))
    que.append(a[1::])
for i in range(1,m+1):
    flag = True
    for j in range(n):
        if i not in que[j]:
            flag = False
    if flag:
        ans += 1
print(ans)

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

for i in range(n):
    for j in range(1, data[i][0] + 1):
        food[data[i][j] - 1] += 1

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

print(ans)

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

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

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

n, m = map(int, input().split())
ka = []
ans = 0
for i in range(n):
    ka_memo = list(map(int, input().split()))
    ka.append(ka_memo[1:])

for i in range(1, m + 1):
    flg = True
    for j in range(n):
        if i not in ka[j]:
            flg = False
            break
    if flg:
        ans += 1
print(ans)

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

sum=0
for i in range(1,m+1):
    flg=True
    for j in range(n):
        if i not in l[j]:
            flg=False
            break
    if flg==True:
        sum+=1
print(sum)

Solution (Python):
import collections
N, M = map(int, input().split())
ans = collections.defaultdict(int)
for i in range(N):
  tmp = list(map(int, input().split()))
  tmp = tmp[1:]
  for j in tmp:
    ans[j]+=1
  
maxnum = max(ans.values())
if maxnum == N:
  anslist = [kv[0] for kv in ans.items() if kv[1] == maxnum]
  print(len(anslist))
else:
  print(0)

Solution (Python):
ii=lambda:int(input())
miis=lambda:map(int,input().split())
lmiis=lambda:list(map(int,input().split()))

n,m=miis()

k=lmiis()
st=set(k[1:])

for i in range(n-1):
  ki=lmiis()
  st=st&set(ki[1:])

print(len(st))

Solution (Python):
def main():
    n, m = map(int, input().split())
    kas = [list(map(int, input().split())) for _ in range(n)]
    question_dict = {i: 0 for i in range(1, m+1)}
    ans = 0

    for ka in kas:
        a = ka[1:]
        for i in a:
            question_dict[i] += 1

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

    print(ans)


if __name__ == "__main__":
    main()

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

foods = [0] * m

for ans in answers:
    for a in ans[1:]:
        foods[a-1] += 1

cnt = 0
for x in foods:
    if x == n:
        cnt += 1
print(cnt)

Solution (Python):

N,M=map(int,input().split())
food=[1]*(M+1)
for _ in range(N):
    q=list(map(int,input().split()))
    q=q[1:]
    for item in range(M+1):
        if item not in q:
            food[item]=0
print(sum(food))

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

for i in range(N-1):
    a = set(l[i])&set(l[i+1])
    l[i+1] = a
if N==1:
  print(len(l[0])) 
else:
  print(len(a))

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

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

tmp = set(K_A[0][1:K_A[0][0]+1])
for i in range(1,N):
    tmp = tmp & set(K_A[i][1:K_A[i][0]+1])
print(len(tmp))

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

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

Solution (Python):

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



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

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

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

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

print(len(k))

Solution (Python):

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

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

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

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

print(ans)

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

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

Solution (Python):
import sys
import os


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

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

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

    print(len(FOODS))


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

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

print(ans)

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())
ans = False
for _ in range(N):
    tmp = list(map(int, input().split()))
    k = tmp[0]
    a = set(tmp[1:])
    if ans is not False:
        ans = ans & a
    else:
        ans = a
print(len(ans))

Solution (Python):


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

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

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

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

Solution (Python):

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

sys.setrecursionlimit(1000000)
mod = 1000000007

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


if __name__ == "__main__":
    solve()

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

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

def examC():

    return

def examD():

    return

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

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

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

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

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

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

print(len(ans))

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

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

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


arr = [0] * m

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

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

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

print(count)

Solution (Python):



import numpy

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

if __name__=='__main__':
  main()

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

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

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

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

print(snum.count(n))

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

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

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

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

P = [0]*M

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

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

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

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

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

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

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

print(ans)

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(map(int,input().split())) for _ in range(N)]


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

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

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

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

Solution (Python):
from collections import Counter

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

r = []
for row in l:
  for i in row:
    r.append(i)
c = dict(Counter(r))
ans = 0
for value in c.values():
  if value == n:
    ans += 1
print(ans)

Solution (Python):
import math
import string


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


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


n, m = map(int, input().split())
s = set(range(1, m+1))

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

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

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

food = [0] * (m+1)



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

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

print(ans)

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

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

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

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

print(len(Anew))

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

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

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

print(c)

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

Solution (Python):
from collections import defaultdict

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

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

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

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

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

print(c)

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

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

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

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

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

from collections import Counter
dict_M = Counter(menu)

print(dict_M[N])

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

print(cook.count(n))

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

dp = [0]*m

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

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

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

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

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

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


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

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

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

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

print(len(ans))

Solution (Python):



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

M_dic={}

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

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

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

print(count)

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

Solution (Python):

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

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

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

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

print(ans)

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

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

print(sum)

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

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


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

print(ans)

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

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())
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 = [0] * N
A = [None] * N
items = {}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

for i in range(len(A)):
  if A[i]>=N:
    cnt+=1
print(cnt)

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

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

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

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

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

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

print(g)

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

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

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

Solution (Python):


from collections import Counter


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


if __name__ == "__main__":
    main()

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

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

all_like = set(like[0])

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

print(len(all_like))

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

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

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

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

print(len(ansset))