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

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

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

foods = [0 for i in range(M)]

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

    for j in range(inputs[0]):
        foods[inputs[j + 1] - 1] += 1

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

print(ans)

Solution (Python):
def func():
    pass


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

    l = [0] * m
    for i in range(n):
        a = [int(i) for i in input().split()]
        for i, ai in enumerate(a):
            if i == 0:
                continue
            l[ai - 1] += 1

    print(l.count(n))


if __name__ == '__main__':
    main()

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

print(co)

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

I = [int(j) for j in input().split()]
k = I.pop(0)
ans = set(I)
for i in range(n-1):
    I = [int(j) for j in input().split()]
    k = I.pop(0)
    ans = ans & set(I)

print(len(ans))

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

ans = [a // N for a in ans]
print(sum(ans))

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

d = {}
for i in range(N):
  K = A[i][0]
  for j in range(1,K+1):
    A[i][j]
    if(A[i][j] in d):
      d[A[i][j]] += 1
    else:
      d[A[i][j]] = 1
cnt = 0
for k, v in d.items():
  if(v == N):
    cnt += 1
print(cnt)

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

for i in range(N):
	A = list(map(int,input().split()))
	for j in range(len(A)):
		if j == 0:
			continue
		else:
			cnt[A[j]] += 1

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

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

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

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

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

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

print(res)

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

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

menu = [0] * m
for i in range(n):
    ka = list(map(int, input().split()))
    for a in ka[1:]:
        menu[a-1] += 1
res = 0
for i in menu:
    if i == n:
        res += 1
print(res)

Solution (Python):
from collections import Counter

n, m = map(int, input().split())
s = []
for i in range(n):
    a = list(map(int, input().split()))
    del a[0]
    for j in range(len(a)):
        s.append(a[j])
ans = 0
sS = Counter(s)
for i in sS.values():
    if i == n:
        ans += 1
print(ans)

Solution (Python):
import numpy as np

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

current = set(A_list[0])
for foods in A_list:
    foods = set(foods)
    current = current & foods
print(len(list(current)))

Solution (Python):
import math
import copy
import bisect







def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())
m=nCast(inputArr1(n[0]))



def func():
    
    s=set(m[0][1:])
    for mm in m:
        tmp=set(mm[1:])
        s=s&tmp
    return len(s)
        


print(func())

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

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

Solution (Python):
N, M = map(int,input().split())
d = {}
for i in range(N):
    l = list(map(int, input().split()))
    for ak in l[1:]:
        if ak in d:
            d[ak] += 1
        else:
            d[ak] = 1

cnt = 0
for k in d.keys():
    if d[k] == N:
        cnt+=1

print(cnt)

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

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    n, m = get_int_list()
    kas = []
    for _ in range(n):
        kas.append(get_int_list())

    counter = Counter()
    for ka in kas:
        for x in ka[1:]:
            counter[x] += 1
    print(len(list(filter(lambda x: x == n, counter.values()))))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N,M = [int(_) for  _ in input().split()]
sA = set([int(_) for  _ in input().split()][1:])
for _ in range(N-1):
    sA &= set([int(_) for  _ in input().split()][1:])
print(len(sA))

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

Mlist = [0]*M
for x in range(N):
    cache = [int(x) for x in input().split()]
    for x in cache[1:]:
        Mlist[x-1] = Mlist[x-1]+1

count = 0
for x in Mlist:
    if x == N:
        count += 1

print(count)

Solution (Python):

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

k = [[int(i) for i in input().split()] for i in range(n)]
v = [0]*31
for i in range(n):
    for j in range(k[i][0]):
        v[k[i][j + 1]] += 1
count = 0
for i in range(len(v)):
    if v[i] == n:
        count += 1
print(count)

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()
    KA = []
    [KA.append(LI()) for i in range(N)]

    result = 0
    for i in KA[0][1:]:
        if all([i in j[1:] for j in KA]):
            result += 1

    print(result)

main()

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

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

for x in range(0,N):
    A = list(map(int,input().split()))
    for y in A[1:]:
        likelist[y] += 1

answer = likelist.count(N)
print(answer)

Solution (Python):
from collections import Counter
n,m = map(int,input().split())
many  =[]
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,a[0]+1):
        many.append(a[j])

ans = Counter(many).most_common()
count = 0
for i in range(len(ans)):
    if ans[i][1] == n:
        count += 1

print(count)

Solution (Python):
N, M = (int(x) for x in input().split())
lst = [0 for _ in range(M)]
for _ in range(N):
  A = tuple(int(x) for x in input().split())
  for a in A[1:]:
    lst[a-1] += 1
print(lst.count(N))

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

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

print(ans)

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

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

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

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

count = 0
sum= 0
for i in A[0]:
    for j in range(a):
        if(i in A[j]):
            count+=1
    if(count == a):
        sum+=1
    count= 0
print(sum)

Solution (Python):
n, m = map(int, input().split())
counter = [0] * m
for _ in range(n):
    suki = list(map(int, input().split()))
    for t in suki[1:]:
        counter[t-1] += 1
print(counter.count(n))

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

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)
N,M = map(int, input().split())
for i in range(N):
    tmp = list(map(int,input().split()))
    for j in range(1,len(tmp)):
        dic[tmp[j]] += 1

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

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

likedByAll = [True for _ in range(M)]
for i in range(N):
    for m in range(1,M+1):
        if m not in A[i]:
            likedByAll[m-1] = False
ans = 0
for liked in likedByAll:
    if liked:
        ans += 1
print(ans)

Solution (Python):



from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

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

t = [0] * (m+1)

for _ in range(n):
    ka = [int(x) for x in input().split()]
    for a in ka[1:]:
        t[a] += 1

print(sum(1 for x in t if x == n))

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


for i in [0]*N:
	t = list(map(int,input().split(' ')))
	t = set(t[1:])
	A &= t
print(len(A))

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

Solution (Python):
N,M=map(int,input().split())
like=[True]*M
for _ in range(N):
    A=list(map(int,input().split()))[1:]
    F=[False]*M
    for a in A:
        F[a-1]=True
    for i in range(M):
        like[i]=like[i]&F[i]
print(like.count(True))

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 _ in c.values():
    if _ == N:
        ans += 1

print(ans)

Solution (Python):
n, m = map(int, input().split())
index=0
listL=[]
while index < n:
    listA=list(map(int, input().split()))
    del listA[0]
    if index==0:
        listL=listA
    else:
        index2=0
        while index2 < len(listL):
            if listL[index2] in listA:
                pass
            else:
                del listL[index2]
                index2-=1
            index2+=1
        if len(listL)==0:
            print(0)
            break
    index+=1
if index==n:
    print(len(listL))

Solution (Python):
N, M = map(int, input().split())
food = [0 for _ in range(M + 1)]
for _ in range(N):
    lst = list(map(int, input().split()))
    for item in lst[1:]:
        food[item] += 1
ans = 0
for item in food:
    if item == N:
        ans += 1
print(ans)

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

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

Solution (Python):

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

numset = set()
for i in range(1, 31):
    numset.add(i)

for i in range(n):
    numset= set(c[i][1:]) & numset
print(len(numset))

Solution (Python):
N,M = list(map(int, input().split()))
data = [0]*30
for i in range(N):
  ai = list(map(int, input().split()))
  ai.remove(ai[0])
  for item in ai:
    data[item-1] += 1

count = 0
for item in data:
  if item == N:
    count += 1

print(count)

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

cnt = 0
for i in range(m):
    if M[i] >= n:
        cnt += 1
print(cnt)

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

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

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

L=[0 for i in range(M+1)]

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

Solution (Python):
n,m=map(int,input().split())
B=[0 for i in range(31)]
for i in range(n):
  A=list(map(int,input().split()))
  k=A[0]
  for i in range(1,k+1):
    B[A[i]]+=1
print(B.count(n))

Solution (Python):
a,b=map(int, input().split(" "))
for i in range(a):
    if i ==0:
        arr=list(map(int, input().split(" ")))[1:]
    else:
        tmp=set(list(map(int, input().split(" ")))[1:])
        arr=(set(arr) & set(tmp))

print(len(arr))

Solution (Python):
N, M = map(int, input().split())
foodlist = [0 for i in range(M)]
for i in range(N):
    food = list(map(int, input().split()))
    food.pop(0)
    for items in food:
        foodlist[items-1]+=1
cnt = 0

for i in range(M):
    if(foodlist[i] == N): cnt+=1
print(cnt)

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())



a,b= (int(i) for i in input().split())      










c = []
for i in range(a):
    d = [int(i) for i in input().split()]
    d.pop(0)
    c.append(d)
s = set(c[0])
for i in range(1,a):
    s = s.intersection(set(c[i]))
print(len(s))

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

    result = new_result

print(len(result))

Solution (Python):


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

ans = {}

for _ in range(N):
    K, *A = list(map(int, input().split()))
    for a in A:
        if a in ans:
            ans[a] += 1
        else:
            ans[a] = 1

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

print(count)

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

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

L = [0] * m
for i in ka:
    for j in i[1:]:
        L[j-1] += 1

ans = 0
for i in L:
    if i == n:
        ans += 1
print(ans)

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

R = [0]*M

for i in range(N):
  K, *A = map(int, input().split())
  for k in range(K):
    R[A[k]-1] += 1

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

Solution (Python):


















import collections
import math
def inpl(): return list(map(int, input().split()))


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

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

c = collections.Counter(all_li)

cnt = 0
for i, size in c.most_common():
  if size == N:
    cnt += 1
  else:
    break

print(cnt)

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

Solution (Python):

def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    K = []
    A = []
    for i in range(N):
        buf = input()
        buflist = buf.split()
        K.append(int(buflist[0]))
        A.append(list(map(int, buflist[1:])))
    liked = []
    for i in range(M):
        liked.append(0)
    for i in range(N):
        for j in range(K[i]):
            liked[A[i][j]-1] += 1
    liked_count = 0
    for i in range(M):
        if liked[i] == N:
            liked_count += 1
    print(liked_count)

if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split())
A = [list(map(int, input().split()))[1:] for _ in range(n)]
count = set(A[0])
for i in A:
    count = set(count) & set(i)

print(len(count))

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
  al = [int(i) for i in input().split()][1:]
  for j in al:
    d[j] += 1
ans = 0
for k, v in d.items():
  if v == n:
    ans += 1
print(ans)

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

K = []

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

D = [1 for i in range(M)]

for i in K:
  for j in range(len(D)):
    if j + 1 not in i:
      D[j] = 0

print(sum(D))

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

Solution (Python):
n, m = map(int, input().split())
array = []
for i in range(n):
    array.append([int(x) for x in input().split()][1:])
res = [0 for x in range(m+1)]
for j in array:
    for k in j:
        res[k] += 1

cnt = 0
for i in res:
    if i == n:
        cnt += 1
print(cnt)

Solution (Python):
N,M = [int(x) for x in input().split()]
li = [0]*(M+1)
for _ in range(N):
    li2 = [int(x) for x in input().split()]
    for index,i in enumerate(li2):
        if(not index == 0):
            li[i]+=1
counter = 0
for i in li:
    if(i == N):
        counter+=1
print(counter)

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

check = [0] * M

for _ in range(N):
    K, *A = [int(i) for i in input().split()]
    for ai in A:
        check[ai - 1] += 1

count = 0
for ci in check:
    if ci == N:
        count += 1

print(count)

Solution (Python):
n,m=map(int,input().split())
p=list(map(int,input().split()))[1:]
for i in range(n-1):
    k=list(map(int,input().split()))[1:]
    c=[]
    for j in range(len(p)):
        if p[j] in k:
            c.append(p[j])
    else:
        p=c
print(len(p))

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

for i in range(n):
    for j in range(1,len(A[i])):
        
        
        C[A[i][j]]+=1
co=0
for i in range(m+1):
    if C[i]==n :
        co+=1
print(co)

Solution (Python):
from functools import reduce

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

print(len(reduce(lambda a,b: a&b, [set(kk) for kk in k])))

Solution (Python):
from collections import Counter


def main():
    n, m = map(int, input().split())
    cs = Counter()
    for _ in range(n):
        aa = list(map(int, input().split()))[1:]
        for a in aa:
            cs[a] += 1
    print(len([v for k, v in cs.items() if v == n]))


if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
u = [0]*33
for _ in range(n):
	a = list(map(int, input().split()))[1:]
	for i in a:
		u[i] += 1
print(sum(1 if x == n else 0 for x in u))

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

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

for _ in range(N):
    K, *A = map(int, input().split())
    ans = ans & set(A)

print(len(ans))

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

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

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

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

ans = 0
for c in cnt:
    if c == n:
        ans += 1

print(ans)

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

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

checklist=[True for i in range(M)]

for i in range(N):
    A=list(map(int,input().split()))
    minicheck = [False for i in range(M)]
    for a in A[1:]:
        minicheck[a-1]=True
    for i in range(M):
        checklist[i] = checklist[i] and minicheck[i]
count=0
for i in range(M):
    if checklist[i]:
        count+=1
        
print(count)

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

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

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

print(ans)

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

from collections import defaultdict

cs = defaultdict(int)

for r in KA:
    for n in r[1:]:
        cs[n] += 1

result = sum([cs[k] == N for k in cs])

print(result)

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

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

Solution (Python):

from collections import defaultdict
import math
import bisect
import random
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return list(input())
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007


"""
a,b = LI()
if b % a == 0:
    print(a+b)
else:
    print(b-a)
"""


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

"""
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a,a)
n = II()
a = LI()
ans = a[0]
for i in range(1,n):
    ans = gcd(ans,a[i])
print(ans)
"""

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

Solution (Python):


import math
import numpy as np
import random
import copy
import statistics 

N,M = [int(x) for x in input().split()]
likes = []
for i in range(N):
    likes.append([int(x) for x in input().split()][1:])

count = [0 for i in range(M)]
for like in likes:
    for a in like:
        count[a-1] += 1

ans = 0
for c in count:
    if c == N:
        ans += 1
print(ans)

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

Solution (Python):




def main():
    n, m = list(map(int, input().split()))
    ans = [0 for _ in range(m+1)]
    for _ in range(n):
        for a in list(map(int, input().split()))[1:]:
            ans[a] += 1
    print(sum(1 for x in ans if x == n))


if __name__ == '__main__':
    main()

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

memo = [1]*M

for _ in range(N):
  items = tuple(map(int,input().split()))
  
  s = set(items[1:])
  for i in range(1,M+1):
    if i not in s:
      memo[i-1] = 0

print(sum(memo))

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

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

    for l in range(1, a[0]+1):
        count[a[l]] += 1

print(count.count(N))

Solution (Python):
from collections import defaultdict
N, M = [int(i) for i in input().split()]
Like = [[int(i) for i in input().split()] for j in range(N)]

like_dict = defaultdict(int)
for k, *a in Like:
    for e in a:
        like_dict[e] += 1
ans = 0
for e in like_dict.values():
    if e == N:
        ans += 1
print(ans)

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

food = [0 for i in xrange(m + 1)]

ans = 0
for _ in xrange(n):
    l = map(int, raw_input().strip().split())
    for i in xrange(1, len(l)):
        food[l[i]] += 1
        if food[l[i]] == n: ans += 1

print ans

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

a = [0 for i in range(M+1)]

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

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

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

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

res = [0] * 31
for i in range(N):
    for a in KA[i][1:]:
        res[a] += 1
ans = 0
for r in res:
    if r == N:
        ans += 1
print(ans)

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

    foods = set([i for i in range(1, M+1)])
    for i in range(N):
        a = list(map(int, input().split()))
        a = a[1:]
        notina = [x for x in range(1, M+1) if x not in a]
        for x in notina:
            if x in foods:
                foods.remove(x)
    
    print(len(foods))


def main():
    solve()


if __name__ == '__main__':
    main()

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

s={}
for _ in range(n):
  *b,=map(int,input().split())
  b=b[1:]
  a=set(b)
  if not s:
    s=a
  else:
    s=s&a
print(len(s))

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

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

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

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

N, M = inpl()
food = set(inpl()[1:])
for _ in [0]*(N-1):
    food &= set(inpl()[1:])
print(len(food))

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

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

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

ans = 0
for i in cnt:
    if i == n:
        ans += 1
print(ans)