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())
nums = [list(map(int,input().split())) for i in range(n)]

l = [0] * m
for i in range(n):
    for elem in nums[i][1:]:
        l[elem-1] += 1

print(l.count(n))

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

print(c.count(N))

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


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

Solution (Python):
N, M = map(int,input().split())
ans = [1] * M
li = [i for i in range(1,M+1)]
for i in range(N):
    a = [int(i) for i in input().split()[1::]]
    for i in set(li) - set(a):
        ans[i-1] = 0

print(sum(ans))

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

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

x = [True] * m

for i in a:
    y = i[0]
    xx = [False] * m
    for j in range(y):
        xx[i[j + 1] - 1] = True
    for j in range(m):
        if xx[j] == False:
            x[j] = False

print(sum(x))

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 = S & set(a)

print(len(S))

Solution (Python):
import copy

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

common = list(range(1,m+1))
for i in range(n):
  like = [int(i) for i in input().split()][1:]
  for j in common[::-1]:
    if j not in like:
      common.remove(j)
  
print(len(common))

Solution (Python):
n, m = map(int, raw_input().split())
	
a0 = map(int, raw_input().split())
if n == 1:
	print a0[0]
else:
	a1 = map(int, raw_input().split())
	com = set(a0[1:]) & set(a1[1:])
	if n == 2:
		print len(list(com))
	else:
		for i in range(n-2):
			a1 = map(int, raw_input().split())
			com = com & set(a1[1:])
		print len(list(com))

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 = map(int,input().split())
A = []
counter = 0
ans = 0
for i in range(N):
    l = input().split()
    l.remove(l[0])
    A = A + l

for k in range(M):
    y = k+1
    counter = A.count(str(y))
    if counter == N:
        ans += 1
print(ans)

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

def hantei(x):
  for j in range(N):
    if x not in List[j][1:]:
      return(0)
  return(1)

ans = 0
for i in range(1,M+1):
  ans = ans + hantei(i)
print(ans)

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 = map(int, input().split())
lis = [[int(x) for x in input().split()] for _ in range(N)]
ans = 0
for item in range(1, M + 1):
  for i in lis:
    if not item in i[1:]:
      break
  else:
    ans += 1
print(ans)

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

for i in range(1, N):
    for j in range(K[i]):
        if A[i][j] in counter[i-1]:
            counter[i].append(A[i][j])

print(len(counter[N-1]))

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

flags = [0 for _ in range(M)]
counter = 0
for i in range(M):
    i += 1
    for j in range(N):
        if not i in A[j]:
            flags[i-1] = 0
            break
        else:
            flags[i-1] = 1
    i += 1
print(flags.count(1))

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

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

ans = 0
Alist = [flatten for inner in A for flatten in inner]
for i in set(Alist):
    if Alist.count(i) == N:
        ans += 1
print(ans)

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

d = {}

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

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

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

print(len(list(filter(lambda x: x == n, d.values()))))

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

Solution (Python):
n, m = map(int, input().split())
all_like = list(range(1, m + 1))
for i in range(n):
    fav_list = list(map(int, input().split()))
    remove_list = []
    for j in all_like:
        if j not in fav_list[1:]:
            remove_list.append(j)
    for j in remove_list:
        all_like.remove(j)
print(len(all_like))

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

A = []
for i in range(N):
    array = list(map(int,input().split()))
    del array[0]
    A.append(array)

for j in range(N):
    for cnt in A[j]:
        suki = int(cnt) - 1
        ninzu[suki] += 1

ans = ninzu.count(N)
print(ans)

Solution (Python):
N, M = map(int, input().split())
pointlist = [0 for i in range(M + 1)]
for i in range(N):
    survey = [int(k) for k in input().split()]
    for j in range(survey[0]):
        pointlist[survey[j + 1]] += 1
print(pointlist.count(N))

Solution (Python):
N, M = map(int, input().split())
all_favorit = list(range(1,M+1))
for i in range(N):
    asking_people= list(map(int, input().split()))
    for j in range(M):
        if all_favorit[j] not in asking_people[1:]:
            all_favorit[j] = 0
count = 0
for i in range(M):
    if all_favorit[i]!= 0:
        count +=1

print(count)

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

from collections import Counter
c = Counter()
for k, *a in ka:
    for b in a:
        c[b] += 1

print(sum(1 for n in c.values() if n == N))

Solution (Python):

import sys

def main():
	N, M = map(int, input().split(" "))
	ankete = []
	for _ in range(N):
		tmp = input().split(" ")
		tmp = [int(s) for s in tmp]
		ankete.append(tmp[1:])
	
	ans = {}
	for i, val in enumerate(ankete):
		for j in val:
			if j in ans:
				ans[j] += 1
			else:
				ans[j] = 1
	
	aaa = 0
	for i in ans.values():
		if i == N:
			aaa += 1
	print(aaa)
	
	
if __name__ == "__main__":
	main()

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

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

cnt = 0
for x in X:
  if x == 0:
    cnt += 1

print(cnt)

Solution (Python):

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

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

for i in range(n):
    like = input().split()
    for j in range(1,len(like)):
        array[int(like[j])-1] += 1

print(array.count(n))

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

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



p = []
for i in range(n):
    p+= le[i][1:]

cnt = 0

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


print(cnt)

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

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

m = [0]*M
ans = 0

for n in range(N):
    a = [int(i) for i in input().split()] 
    for i in a[1:]:
        
        m[i-1] += 1
        if m[i-1] == 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())))

count1 = 0
for i in range(M+1):
    count2 = 0
    for j in range(N):
        if i in K[j][1:M+1]:
            count2 += 1
    if count2 == N:
        count1 += 1
print(count1)

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

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

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

print(len(l))

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

Solution (Python):
K = [None]*30
A = [None]*30
Ms = [0]*31
def main():
    N, M = map(int, input().split())
    for i in range(N):
        K[i], *A[i], = map(int, input().split())
    for i in A:
        if i == None:
            break
        for j in i:
            Ms[j] += 1
    print(Ms.count(N))

main()

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

Solution (Python):

import sys


def solve(n, m, A):
    count = [0] * (m + 1)
    for a in A:
        for i in range(1, len(a)):
            count[a[i]] += 1
    ret = 0
    for c in count:
        if c == n:
            ret += 1
    print(ret)
    return

def main():
    n, m = map(int, input().split())
    a = []
    for i in range(n):
        a.append(list(map(int, input().split())))
    solve(n, m, a)

if __name__ == '__main__':
    main()

Solution (Python):


import sys
input = sys.stdin.readline

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

ans = [0] * (M + 1)

for __ in range(N):
    for like in list(map(int, input().split()))[1:]:
        ans[like] += 1

print(ans.count(N))

Solution (Python):

"""
B - Foods Loved by Everyone
https://atcoder.jp/contests/abc118/tasks/abc118_b

"""
import sys


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


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

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

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

print(result.count(N))

Solution (Python):
n,m = map(int, input().split())
number_list = []
for _ in range(n):
	KA = input().split()
	number_list.extend(KA[1:])
count = 0
for i in range(m + 1):
	if number_list.count(str(i)) == n:
		count += 1

print(count)

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

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

for i in range(N):
    k, *a = map(int, input().split())
    menew = menew & set(a)

print(len(menew))

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

s = set()
for i in range(1, M + 1):
    s.add(i)
for KA in KAs:
    As = KA[1:]
    for i in range(1, M + 1):
        if not i in As and i in s:
            s.remove(i)
ans = len(s)

print(ans)

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

all_results = []

for i in range(N):
    survey = list(map(int, input().split()))
    all_results.append(survey)

counters = {}
for i in range(M):
    counters[i+1] = 0


for i in range(N):
    for j in range(1, len(all_results[i])):
        counters[all_results[i][j]] += 1

counters_list = list(counters.values())
ans = 0
for i in range(len(counters)):
    if counters_list[i] == N:
        ans += 1


print(ans)

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

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

Solution (Python):



import numpy as np
N,M=input().split()
N=int(N)
M=int(M)

l=np.array([1 for i in range(M)])
for i in range(N):
	tmp=input().split()
	K=int(tmp[0])
	
	prefer=np.array([0 for j in range(M)])
	for k in range(K):
		prefer[int(tmp[k+1])-1]=1
	l*=prefer
print(np.sum(l))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    a,b = LI()
    if a%b == 0:
        print(a+b)
    else:
        print(b-a)
    return


def B():
    n,m = LI()
    d = defaultdict(int)
    for i in range(n):
        l = LI()
        for j in range(1,len(l)):
            d[l[j]] += 1
    ans = 0
    for i in d.values():
        if i == n:
            ans += 1
    print(ans)
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == "__main__":
    B()

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

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

A = set()
for i in range(N):
    a = list(map(int, input().split()))
    B = set()
    for j in range(a[0]):
        B.add(a[j+1])
    A = A & B if i > 0 else B

print(len(A))

Solution (Python):
N,M=list(map(int,input().split()))
a=[list(map(int,input().split()))[1:] for _ in range(N)]
s={i for i in a[0]}
for l in a[1:]:
    for i in list(s):
        if not i in l:s.remove(i)
print(len(s))

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

Solution (Python):
n,m=map(int,input().split())
list1=[]
for i in range(n):
  l=list(map(int,input().split()))
  del l[0]
  list1.append(l)
c=0
for i in range(1,1+m):
  b=True
  for j in range(n):
    if i in list1[j]:
      pass
    else:
      b=False
  if b==True:
    c+=1
print(c)

Solution (Python):
NM = [int(i) for i in input().split()]
check = [0] * NM[1]
index = 0
N = NM[0]
while(NM[0] > 0):
    KA = [int(i) for i in input().split()]
    A = KA[1:]
    for i in A:
        check[i - 1] += 1
    NM[0] -= 1
count = 0
for i in check:
    if i == N:
        count += 1

print(count)

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

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

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

print(list_a.count(N))

Solution (Python):
n,m=map(int,input().split());d=[i+1 for i in range(m)]
def listdup(a,b):
  x=[]
  for i in a:
    if i in b:x.append(i)
  return sorted(x)
for i in range(n):
  a=list(map(int,input().split()));a=a[1:];a.sort()
  d=listdup(a,d)
print(len(d))

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

for i in range(N):
    favorite = [int(j)-1 for j in input().split()][1:]
    for f in favorite:
        food[f][i] = True

ans = 0
for f in food:
    if sum(f) == N:
        ans += 1

print(ans)

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

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

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

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

for i in range(m):
    if b[i] == n:
        count += 1

print(count)

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

for i in range(N):
  K,*A = map(int,input().split(' '))
  S &= set(A)
  
print(len(S))

Solution (Python):


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

foods = [0] * M
ans = 0

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

print(ans)

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

cnt = [0]*b
r = 0
for i in range(a):
    li = list(map(int, input().split()))
    
    for j in range(1,len(li)):
        cnt[li[j]-1] +=1
        
        
for k in range(b):
    if(cnt[k] == a):
        r += 1
print(r)

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 sys
n, m = map(int, input().split())
likes = [list(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(len(likes[0]) - 1)
    sys.exit(0)
common = set(likes[0][1:]) & set(likes[1][1:])
for i in range(2, len(likes)):
    common = common & set(likes[i][1:])
print(len(common))

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

def main():
    cnts = [0]*M
    ans = 0

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

    for cnt in cnts:
        if cnt == N:
            ans += 1
    return ans


if __name__ == '__main__':
    print(main())

Solution (Python):


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

all_a = []
for i in range(1,n+1):
    all_a += a[i]

all_a.sort()
rev_a = all_a[:]
rev_a.reverse()
ans = 0

for i in range(1,m+1):
    try:
         if n == (len(all_a) - rev_a.index(i)) - all_a.index(i):
             ans += 1
    except ValueError:
         pass

print(ans)

Solution (Python):
def main():
    N, M = map(int, input().split(' '))
    Ks = [list(map(int, input().split(' ')))[1:] for _ in range(N)]
    
    duplicated = set(Ks[0])
    for i in range(1, len(Ks)):
        a = set(Ks[i])
        duplicated = duplicated & a

    print(len(duplicated))


    
main()

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

count=[0]*M

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

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

tmp = [0]*(M+1)
for a in A:
  for aa in a[1:]:
    tmp[aa] += 1
ans = 0
for t in tmp:
  if t == N:
    ans += 1
print(ans)

Solution (Python):
a,b=map(int,input().split())
for i in range(a):
    n,*a=map(int,input().split())
    if i==0:
        l=a
    else:
        l=set(a)&set(l)
print(len(l))

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

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

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

for i in range(M+1):
    if(l[i] == N):
        ans += 1
    else:
        continue

print(ans)

Solution (Python):


def main():
    n, m = map(int, input().split())
    cand = {j + 1 for j in range(m)}
    for i in range(n):
        ka = list(map(int, input().split()))
        cand &= set(ka[1:])
    print(len(cand))

main()

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

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

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

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

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

Solution (Python):
from itertools import chain

N, M = map(int, input().split())
l = [list(map(int, input().split()))[1:] for i in range(N)]
l = list(chain.from_iterable(l))

food_counts = 0
for i in range(1, M+1):
    if l.count(i) == N:
        food_counts += 1
print(food_counts)

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

Solution (Python):



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

V = {i for i in range(1, M+1)}

for i in range(N) : 
    A = [int(i) for i in input().split()][1:]
    S = set(A)
    V = V & S

print(len(V))

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


for i in range(n):
  k,*b = input().split()
  b = [int(j) for j in b]
  for l in b:
    counter[l-1] +=1
    
print(counter.count(n))

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

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

for v in like_total:
    cnt += v==N
print(cnt)

Solution (Python):
import numpy as np

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

like_total = np.zeros(M)
cnt = 0
for _ in range(N):
    l = [v for v in map(int, input().split())]
    
    for i in range(1, l[0]+1, 1):
        like_total[l[i]-1] += 1



ans = len(np.where(like_total==N)[0])

print(ans)

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

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

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

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

for k in dict:
    if dict[k] == n:
        ans += 1
print(ans)

Solution (Python):
INFO=input().split(" ")

row=int(INFO[0])

for r in range(row):
    temp=input().split(" ")[1:]
    temp = set(map(int, temp))
    if r !=0:
        output = output & temp
    else:
        output = temp
print(len(output))

Solution (Python):

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

V = set(range(1, M+1))
for n in range(N):
	s = list(map(int, input().strip().split()))
	A = set(s[1:])
	V = V & A
				
print(len(V))

Solution (Python):

N, M = map(int, input().split())
K, A = zip(*(
    (int(t[0]), list(map(int, t[1].split())))
    for t in (input().split(maxsplit=1) for _ in range(N))
))


ans = sum(
    all(k in a for a in A)
    for k in range(1, M + 1)
)


print(ans)

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

for i in range(n):
    k = list(map(int,input().split()))
    first_k = k.pop(0)
    for j in range(m):
        counter[j] = counter[j] + k.count(j+1)
    k.clear

print(counter.count(n))

Solution (Python):
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
K = []
for i in range(N):
    K.append(A[i][0])
    del A[i][0]
    
ans = A[0]
for i in range(N-1):
    ans = set(ans) & set(A[i+1])

print(len(ans))

Solution (Python):
n,m=map(int,input().split())
a=[input().split() for _ in range(n)]
s={}
for h in a:
    for r in h[1:]:
        if r in s:
            s[r]+=1
        else:
            s[r]=1
cnt=0
for r in s.values():
    if r==n:
        cnt+=1

print(cnt)

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


def and_array(As,Bs):
    res = []
    for a in As:
        if a in Bs:
            res.append(a)

    return res


tmp = list(map(int, input().strip().split()))[1:]
for i in range(0,N - 1):
    tmp = and_array(tmp, list(map(int, input().strip().split()))[1:])

print(len(tmp))

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

Solution (Python):
from functools import reduce as red

def p(a, b):
    return a&b 

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

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

print(len(red(p, a)))

Solution (Python):
N, M = map(int,input().split())
favorite_lists = []
merged = []
count = 0
for _ in range(0, N):
    favorite_lists.append(input().split()[1:])
for l in favorite_lists:
    merged.extend(l)
for key in range(0, M+1):
    if merged.count(str(key))==N:
        count+=1
print(count)

Solution (Python):

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

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

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

Solution (Python):

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

Solution (Python):
numbers = [int(x) for x in input().split(" ")]
foods = []
for i in range(numbers[0]):
  foods.append([int(x) for x in input().split(" ")])
  foods[i].pop(0)
number = 0
for i in range(numbers[1]+1):
  if all(i in e for e in foods):
    number += 1
print(number)

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

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

kinds = 0
for food in loved_by_everyone:
    kinds += 1 if food == N else 0
print(kinds)

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

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

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

Solution (Python):
from collections import Counter

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

L = []
cnt = 0

for _ in range(n):
    tmp = input().split()
    a = tmp[1:]
    L.extend(a)
    
c = Counter(L)
for k, v in c.items():
    if v==n:
        cnt += 1
print(cnt)

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

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

L = []

for i in range(N):
    L += K[i][1:]
    
cnt = 0
for i in range(M+1):
    if L.count(i) == N:
        cnt += 1

print(cnt)

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