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

Solution (Python):
N, M = map(int, input().split())
KA = [list(map(int, input().split())) for _ in range(N)]
foods = [0]*(M+1)
ans = 0
for ka in KA:
    for i in range(ka[0]):
        foods[ka[i + 1]] += 1

for food in foods:
    if food == N:
        ans += 1

print(ans)

Solution (Python):
def main():
    n, m = map(int, input().split())
    a = [0 for _ in range(m)]
    for _ in range(n):
        *aa, = map(int, input().split())
        for b in aa[1:]:
            a[b-1] += 1
    print(len([aa for aa in a if aa == n]))


main()

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

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

Solution (Python):
n,m=map(int,input().split())
a=[]
for i in range(n):
    p=[int(j) for j in input().split()]
    for j in p[1:]:
        a.append(j)
ans=0
import collections
c=collections.Counter(a)
for i,j in c.most_common():
    if j==n:
        ans+=1
print(ans)

Solution (Python):
import functools

def inter(a,b):
    return list(set(a)&set(b))


def resolve():
    n,m=map(int,input().split())
    a=[list(map(int,input().split())) for i in range(n)]
    a=[i[1:] for i in a]
    print(len(list(functools.reduce(inter,a))))    

resolve()

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

memo = [0 for _ in range(M + 1)]
for i in range(N):
    A = list(map(int, input().split()))[1:]
    for a in A:
        memo[a] += 1

ans = len(list(filter(lambda x: x == N, memo)))
print(ans)

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

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

print(len(foods))

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

se = set(range(M+1))
for _ in range(N):
  enquete = [int(x) for x in input().split()]
  se &= set(enquete[1:])

answer = len(se)
print(answer)

Solution (Python):
n, m = map(int, input().split())
food_dic = {}
for i in range(n):
    k_a = list(input().split())
    foods = k_a[1:]
    for food in foods:
        if food in food_dic:
            food_dic[food] += 1
        else:
            food_dic[food] = 1
count = 0
for food_count in food_dic.values():
    if food_count == n: count += 1

print(count)

Solution (Python):
N, M = list(map(int,input().split()))
C = [0 for _ in range(M)]
for _ in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    for a in A:
        C[a-1] += 1

ans = 0
for c in C:
    if c == N:
        ans += 1

print(ans)

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
for val in l:
    for i in range(1, len(val)):
        d[val[i]] += 1
count = 0
for k in d.keys():
    if d[k] == n:
        count += 1
print(count)

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

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

print(ans.count(n))

Solution (Python):
N,M=map(int,input().split())
list1=list(map(int,input().split()))
del list1[0]
set1=set(list1)
for i in range(N-1):
  list2=list(map(int,input().split()))
  del list2[0]
  set2=set(list2)
  set1=set1&set2
ans=len(set1)
print(ans)

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

li2 = [0]*m
for i in range(len(li)):
    for j in range(1,li[i][0]+1):
        li2[li[i][j]-1] += 1

if max(li2) == n:
    print(li2.count(max(li2)))
else:
    print(0)

Solution (Python):
print(len(set.intersection(*[set(input().split()[1:]) for _ in [0]*int(input().split()[0])])))

Solution (Python):
import functools
print(len(functools.reduce(lambda x, y: x&y,[set(input().split()[1:]) for _ in [0]*int(input().split()[0])])))

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

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


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

ans = 0

for i in range(1,m+1):
  tmp = [1 if j.count(i) == 1 else 0 for j in ls]
  if sum(tmp) == n:
    ans += 1

print(ans)

Solution (Python):
N, M = map(int, input().split())
erase = set()
for i in range(N):
    a = list(map(int, input().split())) 
    
    if i == 0:
        food = a[1:]
    for j in range(len(food)): 
        
        if food[j] not in a[1:]:
            erase.add(j)

print(len(food)-len(erase))

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

print(sum(l))

Solution (Python):
n,m = map(int,input().split())
s = set(range(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 = [list(map(int,input().split())) for _ in range(n)]
c = [0 for _ in range(m)]
for i in range(n):
    for j in range(1,s[i][0]+1):
        c[s[i][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())

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

print(len(ans))

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

li = []

for i in range(n):
  for j in input().split()[1:]:
    li.append(j)

s = set(li)

print(len([i for i in s if li.count(i) == 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()) 

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

print(len(ans))

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

favo_count_of_food = [0 for _ in range(M)]

for i in range(N):
    answers = list(map(int,input().split()))
    for answer in answers[1:]:
        favo_count_of_food[answer-1] += 1
        
print(favo_count_of_food.count(N))

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

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

if __name__ == "__main__":
    main()

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

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

c = collections.Counter(a) 

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

print(ans)

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

for i in range(n):
    l = list(map(int,input().split()))
    s_each = set(l[1:])
    s = s & s_each

print(len(s))

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

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

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

for i in range(1,M+1):
    for j in range(N):
        if not i in A[j]:
            break
        if j==N-1 and i in A[j]:
            ans+=1

print(ans)

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

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


print(food.count(N))

Solution (Python):

import collections


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

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

    c = collections.Counter(a)
    ans = 0
    for val in c.values():
        if val == N:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline
def intinput():return map(int,input().split())

n,m=intinput()
s={i+1 for i in range(m)}
for i in range(n):
    l=list(intinput())
    r=set(l[1:])
    s&=r
print(len(s))

Solution (Python):
n, m = map(int, input().split())
d = {str(i + 1): 0 for i in range(m)}
for _ in range(n):
  for item in input().split()[1:]:
    d[item] += 1

ans = 0
for key in d:
  if d[key] == 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
tmp = 0
u = []
for i in range(n):del a[i][0]
for i in range(n):
    for j in range(len(a[i])):
        if not(a[i][j] in u):u.append(a[i][j])
for i in range(len(u)):
    for j in range(n):
        if u[i] in a[j]: tmp += 1
    if tmp == n: ans += 1
    tmp = 0
print(ans)

Solution (Python):
N, M = map(int, input().split())
k = [i[1:] for i in [list(map(int, input().split())) for i in range(N)]]
k_1 = [flatten for inner in k for flatten in inner]
count_k = 0
for i in range(1, M + 1):
    if k_1.count(i) == N:
        count_k += 1

print(count_k)

Solution (Python):
from collections import Counter;N, M = map(int, input().split());print(len([i for i in Counter([flatten for inner in [i[1:] for i in [[int(i) for i in input().split()] for i in range(N)]] for flatten in inner]).most_common() if i[1] == N]))

Solution (Python):
from collections import Counter
N, M = map(int, input().split())
print(len([i for i in Counter([flatten for inner in [i[1:] for i in [[int(i) for i in input().split()] for i in range(N)]] for flatten in inner]).most_common() if i[1] == N]))

Solution (Python):
from collections import Counter

N, M = map(int, input().split())
K = [i[1:] for i in [[int(i) for i in input().split()] for i in range(N)]]
k = Counter([flatten for inner in K for flatten in inner]).most_common()
print(len([i for i in k if i[1] == N]))

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

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()

like = set([i for i in range(1, M+1)])
for i in range(N):
    As = nl()
    K = As[0]
    As = As[1:]
    like = like & set(As)
print(len(like))

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

na3 = []

for i4 in range(n1):
    na3.append([int(j) for j in input().split()])

na5 = [0] * (n2 + 1)

for i6 in range(n1):
    for i7 in range(na3[i6][0] + 1):
        if i7 != 0:
            na5[na3[i6][i7]] += 1

r8 = 0
for i9 in range(n2 + 1):
    if na5[i9] == n1:
        r8 += 1

print(r8)

Solution (Python):
N = int()
M = int()

N,M=(int(x) for x in input().split())

lis = []
for a in  range(M):
    lis.append(0)

for i in range(N):
    answer = [int(x) for x in input().split()]
    for x in range(1,answer[0]+1):
        lis[answer[x]-1] += 1

print(lis.count(N))

Solution (Python):
n,m = (int(x) for x in input().split())

foods = []
for a in range(m):
	foods.append(0)

for i in range(n):
	answer = [int(x) for x in input().split()]
	for x in range(1,answer[0]+1):
		foods[answer[x]-1] += 1

print(foods.count(n))

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

Solution (Python):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)

N, M = map(int, input().split())
K = [0] * N
A = []
popular = [1] * M
count = 0

for i in range(N):
	tmp = list(map(int, input().split()))
	K[i] = tmp[0]
	A.append(tmp[1:])
	
for i in range(N):
	dislike = [1] * M
	for j in range(K[i]):
		dislike[A[i][j] - 1] = 0
		
	for k in range(M):
		if dislike[k] == 1:
			popular[k] = 0

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

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

for i in range(N):
    A.append([int(m) for m in input().split()])
    A[i].pop(0)
cnt =0
for i in range(1,M+1):
    flag = 1
    for k in range(N):
        if i not in A[k]:
            flag = 0
    if flag == 1:
        cnt += 1
        

print(cnt)

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

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

print(len(s))

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

cnt = [0]*M

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

print(cnt.count(N))

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

cnt = [0]*M

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

print(cnt.count(N))

Solution (Python):
from collections import defaultdict
N,M = list(map(int,input().split(" ")))
di = defaultdict(lambda :0)
for i in range(N):
    temp= list(map(int,input().split(" ")))
    temp = temp[1:]
    for i in temp:
        di[i] += 1
ans = 0
for v in di.values():
    if v == N :
        ans+= 1
print(ans)

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

tlist = [True]*M
for i in range(N):
  alist = list(map(int,input().split()))[1:]
  
  llist = [False]*M
  for a in alist:
    llist[a-1] = True
  for j in range(M):
    if not llist[j]:
      tlist[j] = False
      

print(tlist.count(True))

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

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

Solution (Python):
import collections

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

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

c = collections.Counter(a)

ans = 0
for key,val in c.items():
    if val == N:
        ans += 1
    
print(ans)

Solution (Python):
n,m=map(int,input().split())
a=[]
b=[]
f=list(range(m+1))
for _ in range(n):
  a.append(list(map(int,input().split()))[1:])
for i in range(1,m+1):
  g=0
  for j in range(n):
    if i not in a[j]:
      g=1
      break
  if g==0:
    b.append(i)
print(len(b))

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

for answer in answers:
    for i in answer:
        foods[i - 1] = foods[i - 1] + 1

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

print(ans)

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

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

for v in dct.values():
  if (v == N):
    ans += 1
print(ans)

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



n = konomi[0]
for i in konomi:
  x = set(i) & set(n)
  n = x
  
print(len(x))

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

se = set(range(m+1))
for _ in range(n):
    lst = [int(i) for i in input().split()]
    se &= set(lst[1:])
answer = len(se)
print(answer)

Solution (Python):
def abc():
    n, m = map(int, input().rstrip().split())
    fav = {}
    for i in range(n):
        f = list(map(int, input().rstrip().split()))
        for x in f[1:]:
            fav[x] = fav.get(x, 0) + 1
    print(len([k for k, v in fav.items() if v == n]))


abc()

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

print(sum([i==n for i in d.values()]))

Solution (Python):
N, M = map(int, input().split())
answer = set([])
for i in range(N):
  K_A = [int(x) for x in input().split()]
  K = K_A[0]
  A = K_A[1:]
  if i==0:
    answer = answer.union(set(A))
  else:
    answer = answer.intersection(set(A))
 
print(len(answer))

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

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

se = set(range(M+1))
for _ in range(N):
  enquete = [int(x) for x in input().split()]
  se &= set(enquete[1:])

answer = len(se)
print(answer)

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

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

count = 0
for i in range(1, M + 1):
    flag = True
    for j in range(N):
        if i not in A[j]:
            flag = False
    if flag:
        count += 1
print str(count)

Solution (Python):
N, M = (int(i) for i in input().split())
K = []
A = []
like_dict = {}
for i in range(N):
  KA = [int(j) for j in input().split()]
  K.append(KA[0])
  A.append(KA[1:])
for i in range(M):
  like_dict[i+1] = 0

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

ans = 0

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

print(ans)

Solution (Python):

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

Solution (Python):
n, m = map(int, input().split())
food = {}
for i in range(n):
    a = input().split()[1:]
    food = set(food)&set(a)
    if i == 0:
        food = a

print(len(food))

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

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

print(sum)

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

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

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

print(len(like))

Solution (Python):
inp = input().split()
n = int(inp[0])
m = int(inp[1])
favorite = [] 
for i in range(n):
    tmp = []
    tmp_inp = input().split()
    k = int(tmp_inp[0])
    for i in range(k):
        tmp.append(int(tmp_inp[i+1]))
    favorite.append(set(tmp))


def intersect_set(list):  
    result = list[0]
    for i in range(len(list)-1):
        result = result.intersection(list[i+1])
    return result

print(len(intersect_set(favorite)))

Solution (Python):
inp = input().split()
n = int(inp[0])
m = int(inp[1])
hyou = []
for i in range(n):
    tmp = []
    tmp_inp = input().split()
    k = int(tmp_inp[0])
    for i in range(k):
        tmp.append(int(tmp_inp[i+1]))
    hyou.append(set(tmp))


def intersect_set(list):
    result = list[0]
    for i in range(len(list)-1):
        result = result.intersection(list[i+1])
    return result

print(len(intersect_set(hyou)))

Solution (Python):
n, m = map(int, input().split())
ka = []
for i in range(n):
    ka.append(list(map(int, input().split())))
ok = 0
flag = False
for j in range(1, 31):
    for i in range(n):
        row = ka[i][1:]
        flag = (j in row)
        if not flag:
            break
    if flag:
        ok += 1
        flag = False
print(ok)

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

C = [0]*(M+1)

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

print(C.count(N))

Solution (Python):



N,M = list(map(int,input().split(" ")))
a = [list(map(int,input().split(" "))) for i in range(N)]
tmp = []
for i in range(N):
    del a[i][0]
    tmp+=a[i]
c=0
for _ in list(set(tmp)):
    if tmp.count(_)==N:
        c+=1
print(c)

Solution (Python):
import numpy as np

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

count_num = np.zeros((NM[1], 1))

for i in range(NM[0]):
    num = list(map(int, input().split()))
    del num[0]
    for j in num:
        count_num[j-1] += 1

print(np.sum(count_num == NM[0]))

Solution (Python):
import collections

n, m = map(int, input().split())
lst = [input().split() for i in range(n)]

lst2 = list()
for i in range(0, len(lst)):
    for j in range(1, len(lst[i])):
        lst2.append(lst[i][j])

c = collections.Counter(lst2)

ans_cnt = 0
for moji, cnt in c.items():
    if cnt == n:
        ans_cnt+=1

print(ans_cnt)

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

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

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, M = list(map(int, sys.stdin.readline().split()))
ans =set( list(range(M+1)))
for i in range(N):
    _, *A = list(map(int, sys.stdin.readline().split()))
    ans &= set(A)
print(len(ans))

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

Solution (Python):
N, M = map(int, input().split())
candidate = list(range(1, M+1))
for i in range(N):
    items = list(map(int, input().split()))
    items = items[1:]
    candidate = [cand for cand in candidate if cand in items]
    
print(len(candidate))

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

ans_list = []
for i in range(N):
    k, *A = map(int, input().split())
    for a in A:
        ans_list.append(a)
        
ans = 0
for i in range(1, M+1):
    if ans_list.count(i) == N:
        ans += 1
        
print(ans)

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

for i in range(1,M+1):
    for j in range (N):
        for k in range(1,K[j][0]+1):
            if K[j][k]  == i:
                yobi += 1
        
    if yobi == N:
        ans += 1
        yobi = 0
    
    else:
        yobi = 0

print(ans)

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

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

print(L.count(N))

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

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

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

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

if __name__ == '__main__':
    main()

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

A_li = [0]*M

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


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

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

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

food = [0] * M

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

ans = 0
for count in food :
    if count >= N :
        ans += 1

print(ans)

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

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

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

print(len(hoge))

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


import collections
N, M = map(int, input().split())
co = collections.Counter()
for i in range(N):
  k, *a = map(int, input().split())
  co.update(a)
print(sum(1 for k, v in co.items() if v == N))

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

import collections
counter = collections.Counter()
for i in range(N):
  k, *a = map(int, input().split())
  counter.update(a)

print(sum(1 for k, v in counter.items() if v == N))

Solution (Python):
from collections import defaultdict

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

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


d = defaultdict(int)

for j in a:
    for k in j:
        d[k] += 1

flg = 0
for k in d.values():
    if k == n:
        flg +=1

print(flg)

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

x = [int(x) for x in input().split()][1:]
final = set(x)

for i in range(1, n):
    x = [int(x) for x in input().split()][1:]
    final = final.intersection(x)

print(len(final))

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

m = [0] * (M+1)

for ka in KA:
    for i, s in enumerate(ka):
        if i != 0:
            m[int(s)] += 1

ans = 0
for s in m:
    if s == N:
        ans += 1

print(ans)

Solution (Python):
import collections

N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N)]
favorite = []
count = 0

for i in range(1,A[0][0]+1):
    favorite.append(A[0][i])
for j in range(1,N):
    for k in range(1, A[j][0]+1):
        if A[j][k] in favorite:
            favorite.append(A[j][k])

a = collections.Counter(favorite)
for key,value in a.items():
    if value == N:
        count += 1
print(count)

Solution (Python):
n, m= map(int, input().split())
ka = [input() for i in range(n)]
common = {i for i in range(1,m+1)}
for k in ka:
    tmp = {int(i) for i in k.split()[1:]}
    common = common.intersection(tmp)

print(len(common))

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

Solution (Python):
a,b = map(int, input().split())

allitem = []
for i in range(b):
    allitem.append(i+1)

for i in range(a):
    item = []
    ans = [int(iz) for iz in input().split()]
    for j in range(ans[0]):
        item.append(ans[j+1])

    allitem = list(set(allitem) & set(item))

    
print(len(allitem))

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

U = [[0]*M for i in range(N)]

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

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

print(cnt)