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())
favo = []
count = 0
for i in range(N):
    favo.append([int(x) for x in input().split()][1:])

for j in range(1, M+1):
    if all([j in x for x in favo]):
        count += 1

print(count)

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

Solution (Python):
n,m = map(int,input().split())
k = 0
alist = []
while k < n :
  a = list(map(int,input().split()))
  alist.append(a)
  k += 1

if n == 1 :
  print(len(alist[0])-1)
else:
  for blist in alist :
    b = blist[0]
    blist.remove(b)

  anslist = []
  ans = 0
  i_roop = len(alist[0])
  while i_roop >= 0 :
    if i_roop == 0 :
      break
    else:
      c = min(alist[0])
      for j in range(1,n) :
        if c in alist[j] :
          anslist.append("OK")
          if j == n-1 :
            if len(anslist) == n-1 :
              ans += 1
        else:
          if j == n-1 :
            if len(anslist) == n-1 :
              ans += 1
          break
      alist[0].remove(c)
    anslist = []
    i_roop += -1

if n != 1 :
  print(ans)

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

for l in range(len(flag)):
  if flag[l] == N: ans += 1
  else: pass
  
print(ans)

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

like = []
cnt = 0

for i in range(N):
	like.append([int(x) for x in input().split()][1:])

for j in range(1, M+1):
	if all([j in x for x in like]):
		cnt += 1

print(cnt)

Solution (Python):

"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""



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



"""
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
print(gcd_list(a))
"""

Solution (Python):


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

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

Solution (Python):


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()

C = Counter()
for _ in range(N):
    l = LIST()
    l = l[1:]
    for a in l:
        C[a] += 1

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

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

for _ in range(n):
    _, *o = map(int, input().split())
    for x in o:
        res[x - 1] += 1

ans = sum(1 for x in res if x == n)

print(ans)

Solution (Python):
def main():
    N, M = map(int, input().split())
    result = [0] * (M + 1)
    for _ in range(N):
        row = list(map(int, input().split()))
        A = row[1:]
        for num in A:
            result[num] += 1

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


if __name__ == "__main__":
    main()

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

for i in range(n):
    _, *o = map(int, input().split())
    for x in o:
        res[x - 1] += 1

ans = sum(1 for x in res if x == n)

print(ans)

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

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[x - 1] += 1

ans = sum(1 for x in res if x == n)

print(ans)

Solution (Python):
if __name__ == '__main__':
    n, m = map(int, raw_input().split(" "))
    answers = []

    answer = set(raw_input().split(" ")[1:])
    for x in range(n-1):
        answer = answer.intersection(raw_input().split(" ")[1:])

    print(len(answer))

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

for i in range(N):
  Nlist=list(map(int,input().split()))
  if i==0:
    answerlist=Nlist[1:]
  else:
    answerlist_update=[]
    for j in range(len(answerlist)):
      if answerlist[j] in Nlist[1:]:
        answerlist_update.append(answerlist[j])
    answerlist=answerlist_update
print(len(answerlist))

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

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

for _ in range(n):
  likes = list(map(int, input().split()))[1:]
  candidate = [x for x in candidate if x in likes]
  
print(len(candidate))

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

foods = dict(zip([i+1 for i in range(M)], [0 for i in range(M)]))

for i in range(N):
    A = list(map(int, input().split()))[1::]
    for f in A:
        foods[f]+=1
ans = 0
for count in foods.values():
    if(count == N):
        ans += 1

print(ans)

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

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

k = []
a = []

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




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

for i in range(n):
    for j in range(len(a[i])):

        if a[i][j] != 0:
            ans[a[i][j]-1] += 1



num = 0

for i in range(len(ans)):
    if ans[i] == n:
        num += 1

print(num)

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

fav=[0 for x in range(M+1)]
for i in range(N):
  A=[int(x) for x in input().split()]
  for j in range(A[0]):
    fav[A[j+1]]+=1
ans=0
for c in fav:
  if c==N:
    ans+=1
print(ans)

Solution (Python):




def solve(string):
    string = string.split("\n")
    n, m = map(int, string[0].split())
    ans = {i + 1 for i in range(m)}
    for loves in string[1:]:
        ans &= set(map(int, loves.split()[1:]))
    return str(len(ans))


if __name__ == '__main__':
    base = input()
    n, m = map(int, base.split())
    tmp = [base]
    for _ in range(n):
        tmp.append(input())
    print(solve('\n'.join(tmp)))

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

for _ in range(N):
    IN = input().split()
    
    A = [int(a) for a in IN[1:]]
    G = [i in A for i in range(1, M + 1)]
    F = [F[i] and G[i] for i in range(M)]
print(F.count(True))

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

Solution (Python):
N,M=[int(i) for i in input().split(" ")]
vote=[0 for i in range(M)]
for i in range(N):
    K,*A=[int(i) for i in input().split(" ")]
    for k in A:
        vote[k-1]+=1
print(sum([1 for i in vote if i==N]))

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

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

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

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

    a = []
    for _ in range(n):
        r = [int(s) for s in input().split()][1:]
        a.append(r)
    
    print(solve(m, a))

def solve(m, a):
    s = set(range(1, m + 1))

    for i in range(len(a)):
        s = s & set(a[i])
    
    return len(s)

main()

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

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

A_list[0].pop(0)
a = A_list[0]
for i in range(1, N):
  A_list[i].pop(0)
  a = set(a) & set(A_list[i])

if len(a)==0:
  print(0)
else:
  print(len(a))

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

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

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

main()

Solution (Python):
a, b = map(int, raw_input().strip().split(' '))

memo = [0 for _ in xrange(b + 1)]
for _ in xrange(a) :
    for x in  map(int, raw_input().strip().split(' '))[1:] :
        memo[x] += 1

print len([0 for x in xrange(len(memo)) if memo[x] == a])

Solution (Python):
N,M = map(int,input().split())
_, *A = map(int,input().split())
s = set(A)
for i in range(N-1):
    _, *B = map(int,input().split())
    s &= set(B)
print(len(s))

Solution (Python):
N,M = (int(x) for x in input().split())
a = [[int(x) for x in input().split()] for i in range(N)] 
food = [0]*(M+1)
count = 0
for i in range(N):
    for j in range(1,a[i][0]+1):
        food[a[i][j]] = food[a[i][j]] + 1
for i in range(M+1):
    if food[i] == N:
        count = count + 1
print(count)

Solution (Python):
person_num, shurui = map(int, input().split())
like_set = set(list(map(int, input().split()))[1:])
for i in range(person_num - 1):
    like_set_kari = set(list(map(int, input().split()))[1:])
    like_set &= like_set_kari
print(len(like_set))

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

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

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

for i in range(m+1):
	if new_li.count(i) == n:
		cnt += 1

print(cnt)

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

l = []

for i in range(N):
	del K_A[i][0]
	for j in range(len(K_A[i])):
		l.append(K_A[i][j])
		
count = 0

for i in range(K+1):
	if l.count(i) == N:
		count  += 1

print(count)

Solution (Python):
n,m=map(int,input().split())
foods=[0 for i in range(m)]
for i in range(n):
	buf=list(map(int,input().split()))
	k=buf[0]
	for i in range(k):
		foods[buf[i+1]-1]+=1
		
num=0
for i in range(m):
	if foods[i]==n:
		num+=1

print(num)

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

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

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

Solution (Python):

N, M = map(int, input().split())
ans = [0] * M
for _ in range(N):
    K, *A = list(map(int, input().split()))
    for x in A:
        ans[x - 1] += 1
print(len([x for x in ans if x == N]))

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

Solution (Python):
def read():
    return int(input())

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

n, m = reads()
a = set(input().split()[1:])
for _ in range(n - 1):
  a &= set(input().split()[1:])
print(len(a))

Solution (Python):
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

temp = input_numbers()

n = temp[0]
m = temp[1]

like = []
for i in range(n):
    like += [input_numbers()]

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

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

count = 0

for i in ls:
    if(i == n):
        count += 1

print(count)

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

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

 
print(nop.count(n))

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

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



print(nop.count(n))

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

Solution (Python):
from collections import Counter

def parse_line(line, type=int):
	return [type(x) for x in line.split(' ')]

def main():
	n, m = parse_line(input())
	counter = Counter()
	for _ in range(n):
		k_choices = parse_line(input())
		choices = k_choices[1:]
		for choice in choices:
			counter[choice] += 1
	print(len([x for x in counter.values() if x == n]))


	

if __name__ == '__main__':
	main()

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

nokori=[0]*(M+1)
  
for i in range(0,N):

  kk=list(map(int,input().split(" "))) 
  K=kk[0]
  del kk[0]
  
  for j in kk:
    nokori[j]+=1
    
  
  
for ii in nokori:
  count+=(ii==N)
print(count)

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

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

marray = [0] * m
count = 0

for i in e:
    for j in i[1:]:
        marray[j-1] += 1

for i in marray:
    if i == n:
        count += 1

print(count)

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

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

print(len(num))

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

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

from collections import Counter
c = Counter()
for i in range(n):
    tmp = list(map(int,input().split()))
    for j in tmp[1:]:
        c[j] += 1
cnt = 0
for i in c:
    if c[i] == n:
        cnt += 1
print(cnt)

Solution (Python):


def main(base, new):
	new_base = []
	for member in base:
		if member in new:
			new_base.append(member)
		else:
			pass
	return new_base


init = input()
base = input().split(' ')[1:]
try:
	while True:
		base = main(base, input().split(' ')[1:])
except:
	pass
print(len(base))

Solution (Python):
n, m = map(int, input().split())
lst = [list(map(int, input().split()))[1:] for _ in range(n)]
set_ans = set.intersection(*map(set, lst))
print(len(set_ans))

Solution (Python):
n,m = map(int,input().split())
data = dict()
for i in range(m):
    data[i+1] = 0
for i in range(n):
    temp = list(map(int,input().split()))
    for k in range(1,temp[0]+1):
        data[temp[k]] += 1
counter = 0
for i in data:
    if data[i] == n:
        counter += 1
print(counter)

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  A = set(list(range(1, M+1)))
  for _ in range(N):
    B = set(list(map(int, input().split()))[1:])
    A = A & B
  print(len(A))


if __name__ == '__main__':
  main()

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

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

a = []
k = []

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


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


for i in range(n):
    for x in a[i]:
        ans[x-1] += 1

temp = 0

for x in ans:
    if x == n:
        temp += 1

print(temp)

Solution (Python):

from sys import stdin


s_in = lambda: stdin.readline()[:-1]  
d_in = lambda: int(stdin.readline())  
ds_in = lambda: list(map(int, stdin.readline().split()))  


N, M = ds_in()

all_loved = set([i for i in range(1, M+1)])
for _ in range(N):
    loved = set(ds_in()[1:])
    all_loved = all_loved.intersection(loved)

print(len(all_loved))

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

for person in range(0,N):
    L = list(map(int,input().split()))
    for kind in range(1,L[0]+1):
        K[L[kind]] += 1
print(K.count(N))

Solution (Python):
n, m = map(int, input().split())
out = []
for x in range(n):
    temp = list(map(int, input().split()))[1:]
    if x == 0: out = temp
    else:
        out = list(set(out).intersection(set(temp)))
print(len(out))

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

As = set(range(1,M+1))
for i in range(N):
    temp = list(map(int, input().split(' ')))
    k = temp[0]
    As = As & set(temp[1:])

print(len(As))

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

for i in range(n):
  a = list(map(int, input().split()))
  b = {a[i] for i in range(1,a[0]+1)}
  if i == 0:
    x = b
  else:
    x = x & b

print(len(x))

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

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[i][x - 1] = True

res = list(zip(*res))

ans = sum(1 for x in res if all(x))

print(ans)

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

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[i][x - 1] = True

ans = 0
res = list(zip(*res))

for i, x in enumerate(res):
    if all(x):
        ans += 1

print(ans)

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

Solution (Python):
N, M = map(int, input().split())
dic = {}
for i in range(0, N):
    Ak = list(map(int, input().split()))[1:]
   
    for v in Ak:
        if v in dic.keys():
            dic[v] += 1
        else:
            dic[v] = 1    
result = 0
for vals in dic.values():
    if vals == N:
        result += 1

print(result)

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

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

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

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

for i in range(N):
  KA=list(map(int,input().split()))
  for i in range(1, KA[0]+1):
    memo[KA[i]-1]+=1
    
for m in memo:
  if m==N:
    ans+=1
    
print(ans)

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

cnt = [0 for i in range(M)]
for i in range(M):
    for j in range(N):
        if (i + 1) in A[j]:
            cnt[i] += 1
print(cnt.count(N))

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

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

Solution (Python):
n, m = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(n)]
dic = {}
for hobbies in e:
    for i in range(1,len(hobbies)):
        if hobbies[i] in dic:
            dic[hobbies[i]] +=1
        else:
            dic[hobbies[i]] = 1
everyoneLike = []
for key,num in dic.items():
    if num == n:
        everyoneLike.append(key)
print(len(everyoneLike))

Solution (Python):
(N,M) = map(int,input().split())
r = int(-1)
for i in range(N):
  A = list(map(int,input().split()))
  A.pop(0)
  c = 0
  for a in A:
    c |= (1 << (a-1))
  r &= c

ans = sum([(r>>n)&1 for n in range(M)])
print(ans)

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

Solution (Python):
n, m = map(int, input().split())
for i in range(n):
    lst = [int(j) for j in input().split()]
    lst.pop(0)
    if i == 0:
        ans = list(lst)
    else:
        tmp = list(lst)
        for x in lst:
            if x not in ans:
                tmp.remove(x)
        ans = list(tmp)
print(len(ans))

Solution (Python):






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

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





print(like.count(N))

Solution (Python):
from collections import defaultdict
d = defaultdict(lambda:0)
N,M = map(int,input().split())
for i in range(N):
    K = list(map(int,input().split()))
    for j in range(1,K[0]+1):
        d[K[j]] += 1
ans = 0
for key in d:
    if d[key] == N:
        ans += 1
print(ans)

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

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

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

print(len(ans))

Solution (Python):



n, m = map(int, input().split())
food = []
like = 0
for i in range(n):
    food.append(input().split())
    del food[i][0]
for i in range(1, m+1):
    for j in range(n):
        if str(i) in food[j]:
            if j == n-1:
                like += 1
        else:
            break
print(like)

Solution (Python):
def inpl():
    return list(map(int, input().split()))


n, m = inpl()
ans = [0] * m
for _ in range(n):
    A = inpl()
    for a in A[1:]:
        ans[a - 1] += 1
print(len(list(filter(lambda x: x == n, ans))))

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


food_s=set(food)

for i in food_s:
    if food.count(i) == n:
        ans += 1

print(ans)

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


X = [0] * (M+1)

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

print( X.count(N) )

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

Knk=[]
for _ in range(N):
    Knk.append([int(x) for x in input().strip().split()])

ans = [0] * M

for i,Kn in enumerate(Knk):
    for n,A in enumerate(Kn):
        if n == 0:
            continue
        ans[A-1]+=1

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

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

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

print(ans_list.count(N))

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

Solution (Python):
def get_int(): return int(input())
def get_float(): return float(input())
def get_line(): return input().split()
def get_lines(v): return [get_line() for _ in range(v)]
def get_int_line(): return list(map(int, get_line()))
def get_int_lines(v): return [get_int_line() for _ in range(v)]
def get_float_line(): return list(map(float, get_line()))
def get_float_lines(v): return [get_float_line() for _ in range(v)]

N, M = get_int_line()
K = get_int_lines(N)

for i in range(N):
  K[i].remove(K[i][0])

ans = 0
for i in range(M):
  f = True
  for j in range(N):
    ff = len([v for v in K[j] if v == i + 1]) > 0
    if (not ff):
      f = False
  if (f): ans += 1

print(ans)

Solution (Python):




def solveProblem(persons,kinds,orgDataSet):
	kindsDict=[0 for i in range(0,kinds,+1)]
	for i in range(0,persons,+1):
		eachLine = orgDataSet[i]
		length = len(eachLine)
		for j in range(1,length,+1):
			likeKind = eachLine[j]-1
			kindsDict[likeKind]=kindsDict[likeKind]+1
	agreePerson = 0
	for i in range(0,len(kindsDict),+1):
		if kindsDict[i] == persons:
			agreePerson = agreePerson + 1
	answer = agreePerson
	return answer


if __name__ == '__main__':
	N,M = map(int,input().strip().split(' '))
	dataList = []
	for i in range(0,N,+1):
		dataList.append(list(map(int,input().strip().split(' '))))
	solution = solveProblem(N,M,dataList)
	print("{}".format(solution))

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

if len(a_list) == 1:
    print(len(a_list[0]))
    exit()
ans = set(a_list[0])
for a_lis in a_list:
    ans = ans & set(a_lis)

print(len(list(ans)))

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

cnt = [0] * m
for i in range(n):
    a = [int(i) for i in input().split()]
    for ai in a[1:]:
        cnt[ai - 1] += 1

print(cnt.count(n))

Solution (Python):
N,M = map(int, input().split())
food = [0]*(M+1)
for _ in range(N):
    k,*a = map(int, input().split())
    for ai in a:
        food[ai] += 1
        
ans = 0
for f in food:
    if f==N:
        ans += 1
print(ans)

Solution (Python):
N,M = map(int,input().split())
diff = []
for i in range(N):
    like = list(map(int,input().split()))
    like.pop(0)
    diff += like
likesum = 0
for i in range(M):
    if diff.count(i+1) == N:
        likesum += 1
print(likesum)

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

Solution (Python):
import numpy as np

n,m=list(map(int,input().split()))
t=np.zeros(m)
for i in range(n):
  tmp=list(map(int,input().split()))  
  for j in range(tmp[0]):
    t[tmp[j+1]-1] += 1
  
maxIndex = [i for i, x in enumerate(t) if x == n]
print(len(maxIndex))

Solution (Python):
from itertools import chain
from collections import Counter
 
N, M = map(int, input().split(" "))
A = [list(map(int, input().split(" ")))[1:] for _ in range(N)]
 
print(sum(c==N for c in Counter(chain(*A)).values()))

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

Solution (Python):
N,M = input().split()
N = int(N); M = int(M)
F = []
for i in range(N):
    a = input()
    a = [int(x) for x in a.split()]
    del a[0]
    F.append(a)
res = []
for idx in range(1,M+1):
    cnt = 0
    for pep in F:
        if idx in pep:
            cnt += 1
    res.append(cnt)
print(res.count(N))

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())

a_dic = defaultdict(int)
for _ in range(N):
    a_list = list(map(int, input().split()))[1:]

    for a in a_list:
        a_dic[a] += 1

ans = 0
for val in a_dic.values():
    if val == N:
        ans += 1

print(ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    r = set(list(range(1,m+1)))
    for _ in range(n):
        r &= set(LI()[1:])

    return len(r)



print(main())