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

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

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

ans = 0
for i in range(1,m+1):
  for j in range(n):
    if i in li[j]:
      continue
    else:
      break
  else:
    ans += 1
print(ans)

Solution (Python):


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

res = [0 for _ in range(m)]

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

print(sum([res[i]==n for i in range(m)]))

Solution (Python):


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

res = [0 for _ in range(m)]

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

print(res.count(n))

Solution (Python):


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

res = [0 for _ in range(m)]

for i in range(n):
  res_tmp = [0 for _ in range(m)]
  for j in list(map(int,input().split()))[1:]:
    res[j-1] += 1

print(sum([res[i]==n for i in range(m)]))

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

for _ in range(N - 1):
	S0 = list(input().split())
	S = set(S) & set(S0[1:])

print(len(S))

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

x=0
for i in range(1,m+1):
    for j in range(n):
        v.append(a[j].count(i))

for i in range(0,m*n,n):
  
    if v[i:i+n].count(1)==n:
        x+=1

  
print(x)

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

food_list = [ 0 for i in range(m) ]
for i in range(n):
	food = [ int(v) for v in input().split() ]
	for j in range(food[0]):
		food_list[food[j+1]-1] += 1

print(food_list.count(n))

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

dic = [True for _ in range(M)]

for i in range(N):
    K, *A = list(map(int,input().split()))
    for j in range(M):
        if j+1 in A:
            continue
        else:
            dic[j] = False

print(dic.count(True))

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

N, M = map(int, input().split())
A = deque()
ans = [[0]*M for i in range(N)]
counter = [0 for i in range(M)]
counter2 = 0
for _ in range(N):
    A.append(list(map(int, input().split())))

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

for i in range(len(counter)):
    if counter[i] == N:
        counter2 += 1
print(counter2)

Solution (Python):

import collections
N, M = map(int, input().split())
A = [[] for _ in range(N)]
for i in range(N):
    A[i] = list(map(int, input().split()))
All = []
count = 0
for v in A:
    v.pop(0)
    
for v in A:
    for _v in v:
        All.append(_v)
_All= collections.Counter(All)

for v in _All:
    if _All[v] == N:
        count += 1
print(count)

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

all_ka = []
for ka in KA:
    all_ka.extend(ka)
all_ka = collections.Counter(all_ka)
count = 0
for one in all_ka:
    if all_ka[one] == len(KA):
        count += 1
print(count)

Solution (Python):
n,m = (int(x) for x in input().split())
k = [0]*n
a = []
for i in range(n):
    tmp =  input().split()
    k[i] = int(tmp.pop(0))
    a.append(tmp)



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

ans = 0

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

print(ans)

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

Solution (Python):
N, M = map(int, input().split())
a = [input().split() for i in range(N)]
for b in a:
    del b[0]
x = set(a[0])

for b in a:
    x = x & set(b)
print(len(x))

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

print(cnt.count(n))

Solution (Python):
N, M = map(int, input().split())
a = [input().split() for i in range(N)]
for b in a:
    del b[0]
x = set(a[0])

for b in a:
    x = x & set(b)
print(len(x))

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

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

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

print(cnt)

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

print(cnt.count(N))

Solution (Python):
n, m=map(int,input().split())
a=[0]*(m+1)
for _ in range(n):
	s=list(map(int, input().split()))
	for i in range(1, len(s)):
		a[s[i]]+=1
print(a.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 a in A[1:]:
        l[a] += 1
cnt = 0
for d in l:
    if d == n:
        cnt += 1
print(cnt)

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

Solution (Python):
n,m = map(int,input().split())
l = [0] * (m+1)
c = 0
for i in range(1,n+1):
  a = list(map(int,input().split()))
  for k in range(a[0]):
    l[a[k+1]] += 1
for i in range(m+1):
  if l[i] == 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 j in range(1,A[0]+1):
        C[A[j]-1]+=1
print(C.count(N))

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

Solution (Python):

lst_1 = input().split()
N = int(lst_1[0])
M = int(lst_1[1])

lst_A = []

ans = 0

for i in range(N):
    lst_A.append(input().split())

for food_num in range(1, M+1):

    count = 0

    for i in range(0, N):

        list_range = int(lst_A[i][0])

        for j in range(1, list_range + 1):

            if food_num == int(lst_A[i][j]):
                count += 1

    if count == N:
        ans += 1

print(ans)

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

for _ in range(N):
  l.append(list(map(int, input().split()))[1:])
  
for i in range(M):
  if all(i+1 in l0 for l0 in l):
    cnt += 1

print(cnt)

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

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

cnt = 0
for i in list(set(l)):
  if l.count(i) == N:
    cnt = cnt + 1

print(cnt)

Solution (Python):
def sub():
    N, M = [int(e) for e in input().split()]
    memo = [0 for _ in range(M)]
    for i in range(N):
        lines = [int(e) for e in input().split()]
        K = lines[0]
        As = lines[1:]
        for a in As:
            memo[a-1] = memo[a-1] + 1
    count = 0
    for m in memo:
        if m == N:
            count += 1
    print(count)

sub()

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

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

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

Solution (Python):

N,M = map(int, input().split())
A_list=[]
food_list=[]

for i in range(N):
  A_list.append([int(e) for e in input().split()])

for i in range(M):
  food_list.append(0)
  
for i in range(N):
  K=A_list[i][0]
  for j in range(1,K+1):
    
    food_list[A_list[i][j]-1]+=1

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

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

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

print(len(s))

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,a[0]+1):
        l[a[j]]+=1
if max(l)==n:
    print(l.count(max(l)))
else:
    print(0)

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

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,a[0]+1):
        l[a[j]]+=1
if max(l)==n:
    print(l.count(max(l)))
else:
    print(0)

Solution (Python):
N, M = [int(nm) for nm in input().split()]
L = []
for n in range(N):
  KA = [int(ka) for ka in input().split()]
  for ka in range(len(KA)-1):
    L.append(KA[ka+1])
like = 0
for m in range(M):
  if L.count(m+1) == N:
    like += 1
print(like)

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

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

print(ans.count(n))

Solution (Python):





def main():
    N, M = map(int,input().split())
    K = []
    A = []
    for n in range(N):
        d = list(map(int,input().split()))
        K.append(d[0])
        A.append(set(d[1:]))

    res = A[0]
    for a in A:
        res = res & a

    print(len(res))





if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


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

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


if __name__ == '__main__':
    main()

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

for i in range(1,M+1):
    count = 0
    for f_food in list_a:
        f_food[0] = -1
        if(i in f_food):
            count += 1
    if(count == len(list_a)):
            ans += 1
print(ans)

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

for i in range(n):
    for j in ka[i][1:]:
        ans[j-1] += 1

print(ans.count(n))

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

for i in range(n):
    for j in ka[i][1:]:
        ans[j-1] += 1
print(ans.count(n))

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

for i in range(n):
    for j in ka[i][1:]:
        ans[j-1] += 1

print(ans.count(n))

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

for i in range(n):
    for j in range(1, len(ka[i])):
        for k in range(1, m+1):
            if ka[i][j] == k:
                ans[k-1] += 1
                break

print(ans.count(n))

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

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

List = [list(map(int, input().split())) for i in range(n)]
sum = 0

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

print(sum)

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

List = [list(map(int, input().split())) for i in range(n)]
sum = 0

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

print(sum)

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


ans = [[] for i in range(n+1)]

ans[0] = [i+1 for i in range(m)]
for i in range(n):
    for j in val[i]:
        if j in ans[i] :
            ans[i+1].append(j)
        else: pass
print(len(ans[n]))

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


ans = set([int(i) for i in range(1, M+1)])

for n in range(N):
    ans = ans & set(KA[n][1:])

print(len(ans))

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

allcnt = 0
cnt = 0
exist = False
for i in range(1, M + 1):
    cnt = 0
    for j in range(0, N):
        for k in range(1, member[j][0] + 1):
            if member[j][k] == i:
                exist = True
        if exist == True:
            cnt += 1
            exist = False
    if cnt == N:
        allcnt += 1

print(allcnt)

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

def main():
    ans = set()
    [ans.add(int(s)) for s in range(1, M + 1)]
    for _ in range(N):
        _, *a = [int(s) for s in input().split()]
        ans = ans & set(a)
    print(len(ans))

if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int, input().split())
master = [True] * m
for i in range(n):
    d = map(int, input().split())
    d = list(d)
    num = int(d[0])
    d = d[1:]
    table = [False] * (m + 1)
    for j in range(num):
        table[ d[j] - 1 ] = True
    for j in range(m):
        master[j] = master[j] and table[j]

count = 0
for j in range(m):
    if master[j]:
        count += 1
print(count)

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

Ans =[0]*M
for i in K:
  for itr , j in enumerate(i):
    if itr != 0:
      Ans[j-1] += 1

print(Ans.count(N))

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]









n, m = map(int, input().split())
con = []
for i in range(n):
    k = [int(x) for x in input().split()]
    for j in range(1, k[0]+1):
        con.append(k[j])
ans = 0
for i in range(m):
    if con.count(i+1) == n:
        ans += 1
print(ans)

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

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 a[1:]:l[j]+=1
print(l.count(n))

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

my_dict = {}
for line in line_list:
    for param in line:
        if param in my_dict:
            my_dict[param] += 1
        else:
            my_dict[param] = 1
ret = 0
for param in my_dict.items():
    if param[1] == N:
        ret += 1
print(ret)

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

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

print(data.count(n))

Solution (Python):
b, c = map(int, input().split())
chk = {"a":0}
for i in range(b):
        lst = list(map(int, input().split()))
        for j in lst[1:]:
                if(j in chk.keys()):
                        chk[j] += 1
                else:
                        chk[j] = 1
ans = 0
for i in chk.values():
        if i == b:
                ans += 1
print(ans)

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

for _ in range(N):
    for a in input().split()[1:]:
        a = int(a)
        m[a] += 1

ans = 0
for voted in m.values():
    ans += 1 if voted == N else 0
print(ans)

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

fs = [0 for _ in range(M)]
for i in range(N):
    ki = list(map(int, input().split()))
    for n in ki[1:]:
        fs[n-1] += 1

cn = 0
for a in range(M):
    cn += 1 if fs[a] == N else 0
print(cn)

Solution (Python):

"""
Created on Tue May 14 15:12:42 2019

@author: avina
"""

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

Solution (Python):
n,m=map(int,input().split())
a=[[int(x) for x in input().split()] for _ in range(n)]
d={i:0 for i in range(m)}
for i in range(n):
    k=a[i][0]
    for j in range(k):
        d[a[i][j+1]-1] += 1
cnt=0
for key in d:
    if d[key] == n:
        cnt+=1
print(cnt)

Solution (Python):
a, b = map(int,input().split())
list1 = list(range(1,b+1))
list2 = []
for i in range(a):
  c = list(map(int, input().split()))
  d = c[1:]
  for j in d:
    if j in list1:
      list2.append(j)
    else:
      continue     
  list1 = list2.copy()
  list2.clear()
print(len(list1))

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

ans = set( i for i in range(1, m+1) )

for favset in sets:
  ans = ans & favset
  
print(len(ans))

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

N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
ans = [0] * M

for i in range(N):
    v = L[i]
    s = v[1:v[0] + 1]
    
    for v in s:
        ans[v - 1] += 1
        
print(len([v for v in ans if v == N]))

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

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,M = inpl()
likes = [0]*M

for _ in range(N):
    kaa = inpl()
    for i in range(1,kaa[0]+1):
        likes[kaa[i]-1] += 1


ans = 0
for k in likes:
    if k == N: ans += 1
print(ans)

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

Solution (Python):
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    N, M = map(int, line_input())
    food_liked = [0] * M
    for i in range(N):
        person_i = list(map(int, line_input()))
        for a in person_i[1:]:
            food_liked[a-1] += 1
    num_of_everyone_like = 0
    for m in range(M):
        if food_liked[m] == N:
            num_of_everyone_like += 1
    return num_of_everyone_like

  
if __name__ == "__main__":
    print(solve())

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

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

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

print(len(likes))

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

likes = {i for i in range(1, M + 1)}
for i in range(N):
    A = [int(c) for c in input().split()][1:]
    likes &= set(A)
print(len(likes))

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

for i in range(N):
    for j in range(A[i][0]):
        like[A[i][j+1]-1] += 1
        
cnt = 0
for i in range(M):
    if like[i] == N:
        cnt += 1

print(cnt)

Solution (Python):
N, M = map(int, input().split())
like = [i+1 for i in range(M)]
for n in range(N):
    KA = list(map(int, input().split()))
    like = [x for x in KA[1:] if x in like]
print(len(like))

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

cnt = 0    
for m in range(1,M+1):
    for n in range(N):
        if not m in A_list[n][1:]:
            break
    else:
        cnt += 1
print(cnt)

Solution (Python):
N,M=map(int,input().split())
K=[]
like=[]
food=[]
for i in range(N):
    B=[int(h) for h in input().split()]
    K.append(B[0])
    B.remove(B[0])
    for k in range(K[i]):
        like.append(B[k])
  
for j in range(1,M+1):
    food.append(like.count(j))

print(food.count(N))

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

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

f = set()
for i in l:
    if f == set():
        f = i
    else:
        f &= i

print(len(f))

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

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

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

t_list=[]

for i in range(n):
  f_list = list(map(int, input().split()))
  f_list.pop(0)
  for j in range(len(f_list)):
    t_list.append(f_list[j])

count = 0
for k in range(m):
  if t_list.count(k+1) == n:
    count += 1
print(count)

Solution (Python):
N,M = map(int,input().split())
A = list(list(map(int,input().split())) for i in range(N))
like = [1]*M
for _ in A:
    tmp = [0]*M
    for i in _[1:]:
        tmp[i-1] = 1
    for i in range(M):
        like[i] = min(like[i],tmp[i])
print(sum(like))

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

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

items = set(KA[1:])


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

ans = len(items)
print(ans)

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

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

print(sum(count == N for count in counts))

Solution (Python):

if __name__ == '__main__':
    N, M = map(int, input().split())

    KA = list(map(int, input().split()))

    items = set(KA[1:])

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

    answer = len(items)
    print(answer)

Solution (Python):
from collections import Counter
n, m = map(int, input().split())
food_arr = []
total = 0
for i in range(n):
   food_arr += list(map(int, input().split()[1:]))
    
counter = Counter(food_arr)
for key, value in counter.items():
  if value == n:
    total += 1
print(total)

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

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

print(K.count(N))

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

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

result = [1 for i in range(1, M+1) if K[i] == N]
print(sum(result))

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

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

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

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

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

result = 0
for i in range(1, M+1):
    if K[i] == N:
        result += 1

print(result)

Solution (Python):
n,m = (int(j) for j in input().split())
K = [[0]]*n
Count = [0]*m
for j in range(n):
    K[j] = [int(k) for k in input().split()]
for j in range(n):
    for k in range(1,K[j][0] + 1):
        Count[K[j][k] - 1] = Count[K[j][k]-1] + 1
count2 = 0
for j in range(m):
    if Count[j] == n:
        count2 = count2 + 1
print(count2)

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

counter2 = 0
for i in range(1, M + 1):
    counter1 = 0
    for ans in data:
        num = ans[0]
        if i in ans[1 : num + 1]:
            counter1 += 1
        else:
            counter1 = 0
            break
    if counter1 == N:
        counter2 += 1
print(counter2)

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

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

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

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

ans = set([i for i in range(1, m+1)])
for i in range(n):
    a = [int(i) for i in input().split()]
    ans = ans & set(a[1:])

print(len(ans))

Solution (Python):
import numpy as np

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

ss = np.zeros((n,m),int)

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

c = ss.sum(0)

ans = np.sum(c==n)

print(ans)

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

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

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

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

answers=[]
for k in range(1,M+1):
    ans=0
    for i in range(N):
        for j in range(a[i][0]):
            if a[i][j+1]==k:
                ans+=1
    if ans==(N):
        answers.append(k)
print(len(answers))

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

print(ans)

Solution (Python):
from collections import defaultdict
N, M = [int(a) for a in input().split(" ")]
KAs = [[int(a) for a in input().split(" ")] for i in range(N)]
dic = defaultdict(lambda: 0)
for kas in KAs:
    for a in kas[1:]:
        dic[a] += 1
ans = 0
for cnt in dic.values():
    if cnt==N:
        ans+=1
print(ans)

Solution (Python):
a, b = map(int, input().split())
A = []
for i in range(a):
    array = list(map(int, input().split()))
    A.append(array)
B = []
for j, k in enumerate(A):
    if j == 0:
        B = k[1:]
    else:
        B = list(set(k[1:]) & set(B))
print(len(B))

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

import collections
c=collections.Counter(nakami)

a=0
for i in range(m+1):
  if c[i] == n:
    a += 1
  else:
    pass
  
print(a)

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

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

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

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