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



Sample input:
3 4
2 1 3
3 1 2 3
2 3 2


Sample output:
1

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a=range(n)
a= [[0 for i in range(n)] for j in range(m)]
for N in range(n):
    a[N] = list(map(int,input().split()))
b=[]
d=[]
e=0
for N in range(n):
    for M in range(a[N][0]):
        c=int(a[N][M+1])
        b.append(c)
for N in range(m+1):
    if b.count(N)==n:
        e=e+1

#print(b)

print(e)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 21:09:45 2019

@author: iwata
"""

N, M = map(int, input().split())
anew = []         

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

for j in range(1,N):
    a = list(map(int, input().split()))
    for k in range(1, len(a)):
        anew.append(a[k])
    anew_duplicate = [x for x in set(anew) if anew.count(x) > 1]
    anew = anew_duplicate 
print(len(anew_duplicate))

Submission status: Runtime Error

Solution code:
import collections
import itertools

N, M=map(int, input().split())
a = []
for i in range(N):
  b = []
  b = list(map(int, input().split()))
  del b[0]
  a.extens(b)

counter = collections.Counter(a)

mode_v = counter.most_common()[0][-1]
it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)
if len(it)>=N:
	print(len(it)>=N)
else:
  	print(0)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
el = {}
for i in range(N):
    P = list(map(int, input().split())).pop(0)
    if i == 0: el = set(P)
    el = el & set(P)
print(len(el))

Submission status: Runtime Error

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

for mindex in range(0,m):
    for nindex in range(0,n):
        for kindex in range(1,a[nindex][0]+1):
            if a[nindex][kindex] == mindex+1:
                result[mindex]+=1
            else:
                pass
                

print(result.count(n+1))

Submission status: Runtime Error

Solution code:
n, k = [int(i) for i in input().split()]
lines = [set(input().split()[1:]) for i in range(n)]
diff = set(lines[0])
for i in range(1,len(lines)):
  diff = diff&line
print(len(diff))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n):
        listB = []
        for k in range(1,listA[i][0]+1):
        	listB.append(listA[i][k])
        	if listA[0][j] not in listB:
            	break
    else:
    	x += 1
print(x)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
num =0
line_m=[]
line_s=[]
for k in range(M):
    line_m.append(0)
for i in range(N):
    line_s = list(map(int, input().split()))
    for n in range(int(line_s[0])):
        line_m[int(line_s[n+1])] = int(line_m[int(line_s[n+1])]) + 1

for s in range(M):
    if line_m[s] == N:
        num = num+1

print(num)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n+1):
        if listA[0][j] not in listA[i] and listA[0][j] == listA[i][0]:
            break
    else:
    	x += 1
print(x)

Submission status: Runtime Error

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

ka=[]
for i in range(n):
    atmp=list(input().split())
    ka.append(atmp)


like=ka[0][1::]
ans=len(like)

if n>1:
    for i in range(1,n):
        liketmp=ka[i][1::]
        for k in range(0,len(like)):
             if like[k] not in liketmp:
                 if ans>0:
                     ans-=1
                     del like[k]
                     if ans==0:
                         break

print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n+1):
        if listA[0][j] not in listA[i] and listA[0][j] == listA[i][0]:
            break
        x += 1
print(x)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
num =0
line_m=[]
line_s=[]
for k in range(M):
    line_m.append(0)
for i in range(N):
    line_s = list(map(int, input().split()))
    for n in range(int(line_s[0])):
        line_m[int(line_s[n])] = int(line_m[int(line_s[n])]) + 1

for s in range(M):
    if line_m[s] == N:
        num = num+1

print(num)

Submission status: Runtime Error

Solution code:
N, M= (int(i) for i in input().split())
lst = [[int(i) for i in input().split()] for i in range(n)]

Submission status: Runtime Error

Solution code:
N, M=map(int, input().split())
a = []
for i in range(N):
  b = []
  b = list(map(int, input().split()))
  del b[0]
  a.extend(b)
  
c=Counter(a)
    # すべての要素とその出現回数を取り出します。
freq_scores = c.most_common()
    #c.most_common内の最も多い要素[0]の最大出現回数[1]を[0][1]で指定
max_count = freq_scores[0][1]

modes = []
    　#出現回数と最大出現回数が等しいかを確認します。
for num in freq_scores:
	if num[1] == max_count:
    	modes.append(num[0])

print(len(a[modes]))

Submission status: Runtime Error

Solution code:
from collections import Counter
import numpy as np
m,n = [int(i) for i in input().split()]
lis = []
if m ==1:
    a = [int(i) for i in input().split()]
    print(len(a)-1)
else:
    for i in range(m):
        a = [int(i) for i in input().split()]
        lis.append(a)
        if len(lis[i])!=n:
            for j in range(n-len(lis[i])):
                a.append(0)
            lis.pop(i)
            lis.append(a)
    lis = np.array(lis)
    lis2 = []

    lis = np.rot90(lis)

    # print(lis)
    for i in range(len(lis)):
        c = Counter(lis[i])
        d = [j for j in c.keys()]
        lis2.append(d)
    count = 0
    for i in lis2[0]:
        flag = True
        for j in range(len(lis2)):
            if i not in lis2[j]:
                flag = False
        if flag == True:
            count+=1
    print(count)

Submission status: Runtime Error

Solution code:
N, M= (int(i) for i in input().split())
lst = [[int(i) for i in input().split()] for i in range(n)] 
import numpy as np
food = np.zeros((N,M))
for i in range(N):
    for j in range(lst[i][0]):
        #print(lst[i][j+1])
        food[i][lst[i][j+1]-1] = 1
#print(food)
s = np.sum(food, axis=0)
print(len(s[s==N]))

Submission status: Runtime Error

Solution code:
N, M= (int(i) for i in input().split())
lst = [[int(i) for i in input().split()] for i in range(n)] 

import numpy as np
food = np.zeros((N,M))
for i in range(N):
    for j in range(lst[i][0]):
        #print(lst[i][j+1])
        food[i][lst[i][j+1]-1] = 1
#print(food)
s = np.sum(food, axis=0)
print(len(s[s==N]))

Submission status: Runtime Error

Solution code:
N, M= (int(i) for i in input().split())
for num in range(N):
    lst[num] = [int(i) for i in input().split()]
    
food = np.zeros((N,M))
for i in range(N):
    for j in range(lst[i][0]):
        #print(lst[i][j+1])
        food[i][lst[i][j+1]-1] = 1
#print(food)
s = np.sum(food, axis=0)
print(len(s[s==N]))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 21:12:07 2019

@author: yff20
"""

l1 = input().split()

ln = [0] * (int(l1[1])-1)

for num in range(0, int(l1[0])):
   l2 = input().split()
   for index in range(1, len(l2)):
       ln[int(l2[int(index)])-1] += 1
    
count = 0

for i in ln:
    if(i==int(l1[0])):
        count += 1

print(count)

Submission status: Runtime Error

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

konomi = [[0 for j in range(M)] for i in range(N)]

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

kannryou = [1 for j in range(M)]

for i in range(N):
    for j in range(konomi[i-1][0]):
        kannryou[konomi[i][j+1]-1] = 0


        
ans = sum(kannryou)
print(ans)

Submission status: Runtime Error

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

konomi = [[0 for j in range(M)] for i in range(N)]

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

kannryou = [1 for j in range(M)]

for i in range(N):
    for j in range(konomi[i-1][0]):
        kannryou[konomi[i][j+1]-1] = 0



print(kannryou)
print(konomi)

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
k = []
for i in range(0, a[0]):
  b = list(map(int, input().split()))
  del b[0]
  k.append(b)
 
kk = 0
for i in range(1, a[1] + 1):
  if k.count(i) == a[0]:
    kk += 1
print(q)

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3

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

candidates = [i for i in range(N)]

for k in range(M - 1):
    A = map(int, input().split())
    for Ai in A:
        try:
            index = candidates.index(Ai)
            del candidates[index]
        except ValueError:
            pass

print(len(candidates))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

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

candidates = [i for i in range(N)]

for k in range(M - 1):
    A = map(int, input().split())
    for Ai in A:
        try:
            index = candidates.index(Ai)
            del candidates[index]
        except ValueError:
            pass

print(len(candidates))

Submission status: Runtime Error

Solution code:
import numpy as np

N, M = map(int, input().split())
A = np.full((N, M), 0)
for i in range(N):
    Ka = map(int, input().split())
    a = Ka[1:]
    for j in a:
        A[i, j-1] = 1
        
print(np.sum(np.prod(A, axis=0)))

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
k = []
for i in range(0, a[0]):
  b = list(map(int, input().split()))
  del b[0]
  k.append(b)

q = 0
for i in range(1, a[1] + 1)
  if k.count(i) == a[0]:
    q += 1
print(q)

Submission status: Runtime Error

Solution code:
a,b= map(int,input().split())
arr = [0]*a

for x in range(a):
    te = list(map(int,input().split()))
    K = te[0]
    if a != 1:
        for p in range(K):
            arr[te[p+1]-1] += 1
    else:
        arr = list(set(te[1:len(te)]))
h = max(arr)

if h == a:
    print(arr.count(h))
elif a == 1:
    print(len(arr))
else:
    print(0)

Submission status: Runtime Error

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

li = []
for i in range(n):
    x = map(int,input().split())
    li.append(list(x)[1:])
#    print(li)


sumnum = 0 
for i in range(1, m+1):
    num = 0 
    for j in range(n):
        if i not in li[j]:
            num=0
            break
        num = 1 

    if num == 1:
        sumnum+=1
print(sumnum)
~                                                                                                                                                                                                           
~                                                                                                                                                                                                           
~

Submission status: Runtime Error

Solution code:
import copy
N,M = map(int,input().split())
A = list(map(int,input().split()))
x = A.pop(0)
for i in range(N-1):
    B = list(map(int,input().split()))
    B.pop(0)
    y = len(A)
    C = copy.deepcopy(A)
    for j in range(y):
        if C[j] not in B:
            A.pop(j)
    if len(A) == 0:
        break

print(len(A))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
a=np.zeros(m,dtype=int64)
for i in range(n):
    li = list(map(int,input().split()))
    for j in range(li[0]):
        a[li[j+1]-1]=a[li[j+1]-1]+1
ans=0
for i in range(m):
    if a[i]==n:
        ans=ans+1
print(ans)

Submission status: Runtime Error

Solution code:
number=list(map(int,input().split()))
likes=[]
result=0
for i in range(number[0]):
    for j in range(number[1]):
        rawdata=list(map(int,input().split()))
        for k in range(rawdata[0]):
            likes.append(rawdata[k+1])
for i in range(number[1]):
    if likes.count(i+1):
        result+=1
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
man,food = map ( int ,input ().split())
num = set(range(food+1))
for i in range(man) :
    a = list ( map ( int () , input . split ()))
    del a[0]
    num = num & a
plint (len (num) )

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split(" "))
data = []
for i in range(N):
  A = list(map(int, input().split(" ")))
  A_ = A[1:].sort()
  data.append(A_)
  
counter = 0  
for m in range(M):
  flag = 1
  for d in data:
    if m in d:
      flag *= 1
    else:
      flag *= 0
  if flag == 1:
    counter += 1

print(counter)

Submission status: Runtime Error

Solution code:
number=list(map(int,input().split()))
likes=[]
result=0
for i in number[0]:
    for j in number[1]:
        rawdata=list(map(int,input().split()))
        for k in rawdata[0]:
            likes.append(rawdata[k+1])
for i in number[1]:
    if likes.count(i+1):
        result+=1
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let (n, m) = input!(r, usize, usize);
    let mut meal_map: Vec<Vec<bool>> = vec![vec![false; n];m];
    for i in 0..n {
        let person = input!(r, Vec<usize>; m);
        person.into_iter().skip(1).map(|a| meal_map[a-1][i] = true).collect::<Vec<_>>();
    }
    println!("{}", meal_map.into_iter().filter(|a| a.iter().all(|a| *a) ).count());
}

Submission status: Runtime Error

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

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

print(a.count(n))

Submission status: Runtime Error

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

score = [0 for _ in range(m)]
for i in a:
    for food_index in range(1, len(i)):
        if 0 >= food_index:
            continue
        score[i[food_index - 1]] += 1
print(score.count(n))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
x = 0
for j in range(1,listA[0][0]+1):
    for i in range(1,n+1):
        if listA[0][j] not in listA[i]:
            break
        x += 1
print(x)

Submission status: Runtime Error

Solution code:
N, M = list(map(int, raw_input().split()))
K = []

array = []
for i in xrange(M): array.append(0)
for i in xrange(N):
    inputs = list(map(int, raw_input().split()))
    K = inputs[0]
    for j in xrange(K):
        array[inputs[j+1]] += 1

count = 0
for i in xrange(M):
    if array[i] == N: count += 1

print str(count)

Submission status: Runtime Error

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

score = [0 for _ in range(m)]
for i in a:
    for food_index in range(1, len(i)):
        score[i[food_index - 1]] += 1
print(score.count(n))

Submission status: Runtime Error

Solution code:
a = [list(map(int,input().split())) for i in range(n)]
b = set()
for i in range(n):
    a[i].pop(0)
b = set(a[0])
for i in range(n):
    c = set(a[i])
    b = b&c
print(len(list(b)))

Submission status: Runtime Error

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

if N == 1:
    print(res[0][0])
    exit()

s = [0 for i in range(M)]
for i in res:
    for j in i[1:]:
        s[j-1] += 1

count = 0
for i in range(N):
    if s[i] == N:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A_list = [list(map(int, input().split())) for i in N]

x_set = set(A_list[0][1:])
for i in range(1, N):
  x_set = x_set | set(A_list[i][1:])
print(len(x_set))

Submission status: Runtime Error

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

if N == 1:
    print(res[0][0])
    exit()

s = [0 for i in range(M)]
for i in res:
    for j in i[1:]:
        s[j-1] += 1

count = 0
for i in range(N):
    if s[i] == N:
        count += 1

Submission status: Runtime Error

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

Submission status: Runtime Error

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

cnt = 0
for i in range(1,N+1):
    if foods[i-1]==N:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
Likes = [N for _ in range(M)] 
for _ in range(N): 
    temp = [int(i) for i in input().split()]    
    for k in range(1,len(temp)):
        Likes[temp[k-1]] -= 1
print(Likes.count(0))

Submission status: Runtime Error

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

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

print(len(all_set))

Submission status: Runtime Error

Solution code:
n,m = list(map(int,input().split()))
b = [0 for i in range(m)]
for i in range(n):
  ka = list(map(int,input().split()))
  k = ka[0]
  a = ka[1:]
  for j in range(k):
    b[a[j]-1] += 1
c = 0
for i in range(n):
  if b[i] == 10:
    c += 1
print(c)

Submission status: Runtime Error

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

s = None
for d in data:
  if s is None:
    s = set(d[1:])
  else:
    s = s & set(d[1:])
print(len(s))

Submission status: Runtime Error

Solution code:
N, M = [int(x) for x in input().split()]                                                                             │
                                                                                                                     │
likes = [0 for x in range(M)]                                                                                        │
                                                                                                                     │
for n in range(N):                                                                                                   │
    s = [int(x) for x in input().split()]                                                                            │
    K = s[0]                                                                                                         │
    for k in range(K):                                                                                               │
        likes[s[1+k] - 1] += 1                                                                                       │
                                                                                                                     │
print(likes.count(N))

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    dic = {}
    for m in range(1, M + 1):
        dic[m] = 0

    for i in range(N):
        input_raw = read_func().strip().split()
        K = int(input_raw[0])
        for j in range(K):
            dic[int(input_raw[i])] += 1

    count = 0
    for m in dic:
        if dic[m] == N:
            count += 1
    print count


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split())) # 整数
a = []
for i in range(N):
    a.append(list(map(int, input().split())))
    

m_lis= [0 for i in range(M)]
for i in range(N):
    for j in range(a[i][0]):
        m_lis[a[i][j+1]]+=1
        
        

count=0
for i in range(N+1):
    if m_lis[i]==N:
        count+=1
        
print(count)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
food = [0 for i in range(m)]
for i in range(n):
    k = int(input())
    for j in range(k):
        food[int(input())] = 1
print(food.index(0))

Submission status: Runtime Error

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

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

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