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):
import sys
input=sys.stdin.readline
N,M=map(int,input().split())
k_a=[None for i in range(N)]
cnt=0
for i in range(N):
  k_a[i] = list(map(int,input().split()))[1:]
for inde in k_a[0]:
  c = 0
  for j in range(1,N):
    for k in k_a[j]:
      if inde == k:
        c+=1
        break
    if c >= N-1:
      cnt+=1
if N==1:
  print(len(k_a[0]))
else:
  print(cnt)

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

G = []
for i in range(N):
    A = list(map(int,input().split()))
    if A[0] != 0:
        for j in range(1,len(A)):
            G.append(A[j])

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

print(cnt)

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

Solution (Python):


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

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

print(len(s))

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

Solution (Python):
N, M = map(int, input().split())
import sys
ans = 0
lst = []
kari = []
for i in range(N):
    if i == 0:
        lst += list(map(int, input().split()))
        lst = lst[1:]

    else:
        if lst == []:
            print (0)
            sys.exit()
        else:      
            kari = list(map(int, input().split()))

            sakujo = []
            for j in lst:
                if j in kari[1:]:
                    pass
                else:
                    sakujo += [j]


            for k in sakujo:
                lst.remove(k)


        if lst == []:
            print (0)
            sys.exit()


ans = len(lst)
print (ans)

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

result =[]
for i,t in enumerate(target):
     if i == 0:
         result = t[1:]
     else:
         result = list(set(t[1:]) & set(result))
         
print(len(result))

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

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

b = [b for inner in a for b in inner]

for i in range(m):
    ans += (b.count(i+1) == n)

print(ans)

Solution (Python):
from itertools import chain
n,m=map(int,input().split())
a=[0]*(n)
b=[0]*(n)
for i in range(n):
  b[i]=list(map(int,input().split()))
for i in range(n):
  a[i]=b[i][1:]
ans=0
c=[e for p in a for e in p]
for j in range(1,m+1):
  if c.count(j)==n:
    ans+=1
print(ans)

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

ans = K[0][:]
for i in range(1,N):
    ans = list(set(ans) & set(K[i]))

print(len(ans))

Solution (Python):
N,M=list(map(int,input().split()))
Key=[]
cnt=0
a=0
    
if N==1:
    a=input().split()
    print(len(a)-1)

else:    
    
    for i in range(N):
        tmp=input().split()
        for j in range(int(tmp[0])):
            Key.append(int(tmp[j+1]))
    
    for i in range(1,M+1):
        if Key.count(i)==N:
            cnt+=1
    
    print(cnt)

Solution (Python):

import copy

def solve():
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    candidates = copy.deepcopy(A[1:])

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

        copied_candidates = copy.deepcopy(candidates)
        for candidate in copied_candidates:
            if candidate in A:
                continue
            else:
                candidates.remove(candidate)
            
    print(len(candidates))



if __name__ == "__main__":
    solve()

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

B = set(range(1, M + 1))
for _ in range(N):
    A = [int(x) for x in input().split()]
    B &= set(A[1::])
print(len(B))

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

ans = 0
for i in range(m):
    _a = sum([x == i+1 for x in a])
    if _a == n:
        ans += 1

print(ans)

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

ans_list = A[0]
for i in range(N):
  ans_list = set(ans_list) & set(A[i])
print(len(ans_list))

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, A[0][0] + 1):
	flag = True
	a = A[0][i]
	for j in range(1, N):
		if not a in A[j][1:]:
			flag = False
	if flag:
		ans += 1
print(ans)

Solution (Python):



import numpy as np

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

rcd = [[False for c in range(M+1)] for r in range(N)]

for i in range(N):
    KA = list(map(int, raw_input().split()))
    K = KA[0]
    for j in range(1, K+1):
        rcd[i][ KA[j] ] = True

rcd = np.array(rcd)

cnt = 0
for c in range( len(rcd[0]) ):
    if sum(rcd[:,c]) == N:
        cnt += 1

print '{}'.format(cnt)

Solution (Python):
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
fav = [1]*M
for _ in range(N):
    A = inpl()[1:]
    for m in range(M):
        if m+1 in A:
            pass
        else:
            fav[m] = 0
print(sum(fav))

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

for i in range(n):
    k = list(map(int, input().split()))
    for j in k[1:]:
        lst.append(j)
    
for i in range(1, m+1):
    cnt.append(lst.count(i))

print(cnt.count(n))

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

Solution (Python):

import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

def main():
    n, m = readIntN()
    res = set(readIntN()[1:])
    for i in range(n-1):
        res = res.intersection(set(readIntN()[1:]))
    print(len(res))

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
N,M = map(int, input().strip().split(' '))
now = [i for i in range(1,M+1)]
for line in sys.stdin:
  col = list(map(int, line.strip().split(' ')))
  now = [f for f in now if f in col[1:]]
print(len(now))

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

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

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

for i in K:
    for j in i:
        que[j] += 1
for i in que:
    if i == N:
        ans += 1
print(ans)

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

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

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

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

l = [0] * M

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

print(l.count(N))

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

f = set(range(1,M + 1))

for _ in range(N):
  f = f & set([int(x) for x in input().split()][1:])

print(len(f))

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

for i in range(1, M+1):
    x = a.count(i)
    if x == N:
    	cnt += 1

print(cnt)

Solution (Python):
nm = input().split()
n = int(nm[0])
m = int(nm[1])

kalist = []
for i in range(n):
    ka = input().split()
    k = int(ka[0])
    alist = [int(a) for a in ka[1:]]
    kalist.append((k, alist))


aset = None
for k, alist in kalist:
    if aset is None:
        aset = set(alist)
    else:
        aset = aset & set(alist)

print(len(aset))

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

Ms = list(range(1, M+1))
ans = list(range(1, M+1))

for i in li:
    ans = list(set(ans) - (set(Ms) - set(i)))

print(len(ans))

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

N, M = map(int, input().split())
for k in range(N):
    line = input().split()[1:]
    for a in line:
        d[a] += 1


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

Solution (Python):
Ans_list = []
Ans = 0

N,M = map(int, input().split())
for i in range(N):
  KA = list(map(int, input().split()))
  Mylist = KA[1:]
  for j in range(len(Mylist)):
      Ans_list.append(Mylist[j])
for i in range(M+1):
  if Ans_list.count(i)==N:
    Ans += 1
print(Ans)

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

print(memo.count(n))

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

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

SS = []
for k in K:
    for s in k[1:]:
        SS.append(s)

SS_d = [x for x in set(SS) if SS.count(x) > N-1]

print(len(SS_d))

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

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

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

print(len(ans))

Solution (Python):
N,M = map(int,input().split())
X  = list(range(M + 1))
for i in range(N):
    A = list(map(int,input().split()))
    K = A.pop(0)
    X = list(set(X) & set(A))

print(len(X))

Solution (Python):
N, M = map(int,input().split())
 
user = {}
for i in range(N):
    user[i] = list(map(int,input().split()))
 
tmp = list(range(1,31))
for k in user.keys():
    user[k].pop(0)
    tmp = list(set(tmp) & set(user[k]))
print(len(tmp))

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

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

food_count = [0] * m

for p in k:
    for i in range(1, len(p)):
        food_count[p[i]-1] += 1

count = 0
for f in food_count:
    if f == n:
        count += 1

print(count)

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

user = {}
for i in range(N):
    user[i] = list(map(int,input().split()))

tmp = list(range(1,31))
for k in user.keys():
    user[k].pop(0)
    tmp = list(set(tmp) & set(user[k]))
print(len(tmp))

Solution (Python):
N,M = map(int,input().split())
listM = list(range(1,M+1))
for i in range(N):
    K = list(map(int,input().split()))
    K.pop(0)
    a = []
    for j in range(len(listM)):
        if listM[j] not in K:
          	a.append(listM[j])
    for j in range(len(a)):
      	listM.remove(a[j])
print(len(listM))

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

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

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

mask = int("1" * M, 2)
flag = mask

for k, *al in KA:
	tf = 0
	for a in al:
		tf |= 1 << (M - a)
	
	flag &= tf
	
print(bin(flag).count("1"))

Solution (Python):

n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(n)]
data = [0] * m
count = 0

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

for k in range(m):
    if data[k] == n:
        count += 1

print(count)

Solution (Python):
import copy

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

like = list(map(int, input().split()))
like.pop(0)
all_like = set()
for l in like:
	all_like.add(l)
    
for i in range(N-1):
  like = list(map(int, input().split()))
  like.pop(0)
  tmp = copy.deepcopy(all_like)
  for l in all_like:
    if l not in like:
      tmp.remove(l);
  all_like = tmp
print(len(all_like))

Solution (Python):
N,K= map(int,input().split())
L=[]
for i in range(N):
    L.append([int(j) for j in input().split()][1:])
L=[flatten for inner in L for flatten in inner]
ans=[]
for i in set(L):
    if L.count(i)==N:
        ans.append(i)
print(len(ans))

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

a = 0

for i in range(m):
    loved = True
    for j in range(n):
        if ka[j][1:].count(i+1) == 1:
            continue
        else:
            loved = False
            break

    if loved:
        a += 1

print(a)

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

ansLst = [0] * M
for i in range(N):
    for j in range(1, len(kLst[i])):
        ansLst[kLst[i][j] - 1] += 1

ansCnt = 0
for i in ansLst:
    if i == N:
        ansCnt += 1

print(ansCnt)

Solution (Python):


N, M = map(int, input().split())
As = []
for _ in range(N):
    As += list(map(int, input().split()))[1:]

ans = 0
for i in range(1, M + 1):
    ans += 1 if sum([1 for A in As if A == i]) == N else 0

print(ans)

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

foods = list(range(1, M+1))

for i in range(N):
    fav_food = list(map(int, input().split()))
    fav_food = fav_food[1:]
    foods = [food for food in foods if fav_food.count(food) == 1]     
    

print(len(foods))

Solution (Python):
n,m=map(int,input().split())
c=[0]*m
for i in range(n):
    li=list(map(int,input().split()))
    for j in range(li[0]):
        c[li[j+1]-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())
likelist=[]
for n in range(N):
	like=list(map(int,input().split()))
	likelist.extend(like[1:])
everyonelikes=0
for m in range(1,M+1):
	if likelist.count(m) == N:
		everyonelikes += 1
print(everyonelikes)

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

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

count = [0 for i in range(m)]

for j in range(n):
    check = list(map(int, input().split()))
    for k in range(check[0]):
        count[check[k+1] - 1] += 1

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

print(ans)

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

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

print(len(food))

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

listC=listF[0][1:]

for i in range(N-1):
    listC=list(set(listF[i+1][1:]) & set(listC))

print(len(listC))

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

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

dicFood = {}
for _ in range(N):
	food = list(map(int,input().split()))
	for k in food[1:]:
		if k not in dicFood:
			dicFood[k] = 1
		else:
			dicFood[k] +=1
		
count = 0	
for v in dicFood.values():
	if v == N:
		count += 1
		
print(count)

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

listC = listF[0][1:]
for i in range(N-1):
    listC = list(set(listF[i+1][1:]) & set(listC))


print(len(listC))

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

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

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

ans = 0

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

print(ans)

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

temp = [0] * M
for i in range(N):
    for j in range(M):
        temp[j] += box[i][j]
        
print(temp.count(N))

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

Solution (Python):


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


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


a = sum(a, [])



import collections

a = collections.Counter(a)

a = list(a.items())



count = 0

for i, j in a:
    if j >= N:
        count += 1

print(count)

Solution (Python):
n, m = [int(i) for i in input().split()]
liked = [0 for _ in range(m)]
for _ in range(n):
    _input = [int(i) for i in input().split()]
    for i in _input[1:]:
        liked[i-1] += 1
count = 0
for i in range(len(liked)):
    if liked[i] == n:
        count += 1
print(count)

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

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

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

num = [0 for i in range(m+1)]
  
for i in range(n):
  for j in range(1, len(f[i])):
    num[f[i][j]] += 1
    
    
cnt = 0
for i in num:
  if i == n:
    cnt += 1
    
    
print(cnt)

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

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

food = [0] * M
for i in l:
    for j in range(i[0]):
        food[i[j + 1] - 1] += 1

print(food.count(N))

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

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

for i in range(n):
  k = list(map(int,input().split()))
  for j in range(1,k[0] + 1):
    if k[j] not in sum:
      sum[k[j]] = 1
    else:
      sum[k[j]] += 1
for l in sum:
  if sum[l] == n:
    ans += 1
print(ans)

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

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

for i in range(0,n):
  K = list(map(int,input().split()))
  for j in range(1,K[0] + 1):
    if K[j] not in sum:
      sum[K[j]] = 1
    else:
      sum[K[j]] += 1
for k in sum:
  if sum[k] == n:
    ans += 1
print(ans)

Solution (Python):


N, M = map(int, input().split())
sum = {}
ans = 0

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

for k in sum:
    if sum[k] == N:
        ans += 1
print(ans)

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

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

for Ai in A:
    for a in Ai[1:]:
        LIKE[a] += 1

ans = 0
for x in LIKE:
    if x == N:
        ans += 1
print(ans)

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

Solution (Python):
import functools
N, M = map(int, input().split())
A = [set(map(int, input().split()[1:])) for _ in range(N)]
print(len(functools.reduce(set.intersection, A)))

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

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

for i in range(N):
    KA = list(map(int, input().split()))
    A = KA[1:]
    a += A
for j in range(1,M+1):
    if a.count(j) == N:
        ans += 1
print(ans)

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

Solution (Python):
n,m=map(int,input().split());res=[0]*m
for _ in [0]*n:
  _,*o=map(int,input().split())
  for x in o:
    res[x-1]+=1
ans=res.count(n)
print(ans)

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

Solution (Python):
N, M = map(int, input().split())
likeset = set(range(1, M+1)) 
for _ in range(N):
    a, *b = map(int, input().split()) 
    likeset &= set(b) 
print(len(likeset))

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

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

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

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

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

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

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

Solution (Python):
N, M = [int(s) for s in input().split(' ')]
vote = [0] * M
for _ in range(N):
    answer = [int(s) for s in input().split(' ')][1:]
    for a in answer:
        vote[a-1] += 1
vote_all = 0
for v in vote:
    if v == N:
        vote_all += 1
print(vote_all)

Solution (Python):
N,M=map(int,input().split())
TOT=[0]*M
for i in range(N):
  List=[int(i) for i in input().split()]
  List.pop(0)
  List_N=[]
  for j in range (M):    
    if j+1 in List:
      List_N.append(1)
    else:
      List_N.append(0)
  TOTAL=[]
  for k in range(M):
    TOTAL.append(TOT[k]+List_N[k])
  TOT=TOTAL
print(TOT.count(N))

Solution (Python):



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

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

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

print(l.count(n))

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

Solution (Python):
N, M = map(int, input().split())
k = []
for i in range(N):
	l = list(map(int, input().split()))
	del l[0]
	k.append(l)
a = k[0]
for i in range(1, N, 1):
	a.extend(k[i])
	a = [x for x in set(a) if a.count(x) > 1]
print(len(a))

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

bag = {m+1: 0 for m in range(M)}

for n in range(N):
    all_list = list(map(int, input().split()))
    K = all_list[0]
    A = all_list[1:]
    for k in range(K):
        bag[A[k]] += 1

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

print(count)

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


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

for _ in range(N):
    tmp = list(map(int,input().split()))
    like_list = tmp[1:]
    for like in like_list:
        like_count[like] += 1

count = 0
for value in like_count:
    if value == N:
        count += 1

print(count)

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

ans = set(range(m+1))

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

print(len(ans))

Solution (Python):
N, M = map(int, raw_input().split())
menu = []
for i in range(0, M):
	menu.append(0)
for i in range(0, N):
	answer = map(int, raw_input().split())
	for j in range(1, answer[0]+1):
		menu[answer[j]-1] += 1
cnt = 0
for i in range(0, M):
	if menu[i] == N: cnt += 1

print cnt

Solution (Python):
def main():
    n, m = map(int, input().split())
    like_count = [0 for _ in range(m + 1)]

    
    for _ in range(n):
        tmp = list(map(int, input().split()))
        like_list = tmp[1:]
        for like in like_list:
            like_count[like] += 1

    
    count = 0
    for value in like_count:
        if value == n:
            count += 1

    print(count)


main()

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

print(ans)

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

r=set(list(map(int,input().split(" ")))[1:])
for z in range(N-1):
  r=r&set(list(map(int,input().split(" ")))[1:])

print(len(r))

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

KA = []
for i in range(N):
    if i == 0:
        lbe = list(map(int, input().split()))[1:]
    else:
        tmp = []
        for j in list(map(int, input().split()))[1:]:
            if j in lbe:
                tmp.append(j)
        lbe = tmp

print(len(lbe))

Solution (Python):
_,*t=open(0);print(len(set.intersection(*[set(s.split()[1:])for s in t])))

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

print(ans)

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

list_list = []
for i in range(N) :
    line = input().split()
    del line[0]
    list_list.append(line)

s = set(list_list[0])
for i in range(1,N) :
    s = s & set(list_list[i])

print(len(s))

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

d = sum(d,[])

import collections
c = collections.Counter(d)

keys = [k for k , v in c.items() if v == n]
print(len(keys))

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

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

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

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

Solution (Python):
n, m = map(int, input().split())
truely_loved_food = {x for x in range(m + 1)}
for i in range(n):
    li = list(map(int, input().split()))
    k=li[0]
    loved_food = set(li[1:])
    truely_loved_food = truely_loved_food & loved_food
print(len(truely_loved_food))

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

Solution (Python):
import sys
from collections import Counter

N, M = map(int, input().split())
KA_list = []
for i in range(N):
    for j in input().split()[1:]:
        KA_list.append(j)
c = Counter(KA_list)

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

print(ans)