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: Wrong Answer

Solution code:
n, m = [int(i) for i in input().split()]
list_a = [[int(i) for i in input().split()] for j in range(0, n)]
list_ans = [1 for i in range(0, m)]
if n == 1:
    print(list_a[0][0])
    exit()
for i in range(0, n):
    for j in range(1, len(list_a[i])):
        if list_ans[list_a[i][j] - 1] == 1:
            list_ans[list_a[i][j] - 1] = 0
print(sum(list_ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

dp = [0]*m

for i in range(n):
    for j in range(ab[i][0]):
        k = ab[i][j+1]
        dp[k-1] +=1
        

print(dp.count(m))

Submission status: Wrong Answer

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

flg = [0] * (m+1)
for i in range(n):
  for j in range(ka[i][0]):
    food = ka[i][j]
    flg[food] += 1

result = 0
for i in range(m+1):
  if flg[i] == n:
    result += 1
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
k = [list(map(int, input().split())) for i in range(n)]
c = 0
for i in range(n):
    for j in range(1,n+1):
        if j not in k[i][1:]:
            break
    else:
        c+=1
print(c)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
h={i for i in range(1,M+1)}
for _ in range(N):
  a=list(map(int,input().split()))
  a=set(a[1:])
  h-=a
print(len(a))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M = map(int,input().split())
A = [[int(i) for i in input().split()] for _ in range(N)]

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

Submission status: Wrong Answer

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

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

    for k in range(KA[0]):
        like[KA[k]] += 1

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

print(ans)

Submission status: Wrong Answer

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

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

print(sum([i for i in ans if i == N]))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
an_li = list(map(int, input().split()))
an_li.remove(an_li[0])
for i in range(N-1):
    li = list(map(int, input().split()))
    li.remove(li[0])
    for t in an_li:
        if t in li:
            a = 1
        else:
            an_li.remove(t)
print(len(an_li))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=set(range(m+1))
for i in range(n):s=s&set(map(int,input().split()))
print(len(s)-1)

Submission status: Wrong Answer

Solution code:
1

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
l=range(1,m+1)
for i in range(n):
  b=list(map(int, input().split()))
  b.pop(b[0])
  l=set(l)&set(b)

print(len(l))

Submission status: Wrong Answer

Solution code:
MM = input().split()
N =int(MM[0])
M =int(MM[1])
list1 = [i for i in range(M)]
for i in range(N):
  MM = input().split()
  list2 = [int(MM[j]) for j in range(1,int(MM[0])+1)]
  list1 = set(list1)&set(list2)
print(len(list1))

Submission status: Wrong Answer

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

x = [0]*m

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m = map(int, input().split())
arr = np.zeros(m)
for i in range(n):
    ka = np.array([int(i) for i in input().split()])
    for j in range(ka[0]):
        arr[ka[j+1]-1] = 1
ans = int(arr.sum())
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m = map(int, input().split())
arr = np.ones(m)
for i in range(n):
    ka = np.array([int(i) for i in input().split()])
    for j in range(ka[0]):
        arr[ka[j+1]-1] = 0
ans = int(arr.sum())
print(ans)

Submission status: Wrong Answer

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

A=[]
for i in range(N):
  x = [int(i) for i in input().split()]
  A = A + x[1:]

ans = 0
from collections import Counter
for k,v in Counter(A).items():
  print(k,v)
  if v==N: ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#42
N,M = map(int,input().split())
k = list(map(int,input().split()))
k = k[1:]
for i in range(N-1):
    l = list(map(int,input().split()))
    l = l[1:]
    for m in k:
        a = 0
        for n in l:
            if m == n:
                a +=1
                break
        if a ==0:
            k.remove(m)
    
print(len(k))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
kouho=[i for i in range(1,m+1)]
for i in range(n):
    x=list(map(int, input().split()))
    a=x[1:]
    for i in kouho:
        if not i in a:kouho.remove(i)
print(len(kouho))

Submission status: Wrong Answer

Solution code:
import collections
n, m = map(int, raw_input().split(' '))
cc = collections.Counter()
for _ in range(n):
	for a in map(int, raw_input().split(' ')): cc[a] += 1
count =0
for k in cc:
  	if cc[k] == n: count +=1
print count

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())

A = np.zeros((N,M))
for i in range(N):
    a = list(map(int, input().split()))
    a = a[1:]
    A[i, 0:len(a)] = a

for i in range(N):
    a = A[i]
    a = a[(a != 0) & (a < M)]
    if i == 0:
        s = set(list(a))
    else:
        _s = set(list(a))
        s &= _s

print(len(s))

Submission status: Wrong Answer

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

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

s = set(A[0])
for i in range(1,N):
    _s = set(A[i])
    s &= _s
    
ans = len(s)-1
print(ans-1 if ans > 0 else 0)

Submission status: Wrong Answer

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

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

s = set(A[0])
for i in range(1,N):
    _s = set(A[i])
    s &= _s
print(len(s)-1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
    
s = set(list(A[0]))
for i in range(N):
    _s = set(A[i])
    s &= _s

print(len(s))

Submission status: Wrong Answer

Solution code:
N,M = map(int,list(input().split()))
i_list = [0]*M
for i in range(N):
    s = list(input().split())
    for j in range(int(s[0])):
        i_list[int(s[j])-1] += 1
counter = 0
for i in range(M):
    if i_list[i] == N:
        counter += 1   
    
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
K = []
sum = 0
for i in range(N):
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
for T in range(1,len(K)+1):
  B=K.count(T)
  if B == N:
    sum+=1
print(sum)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
x=[]
sum=0
for i in range(n):
  s=list(map(int,input().split()))
  x+=s
for i in range(1,m+1):
  if x.count(i)==n:
    sum+=1
print(sum)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=a[1:]
for i in range(n-1):
  x=list(map(int,input().split()))
  x=x[1:]
  for j in a:
    if j not in x:
      a.remove(j)
print(len(a))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=a[:1]
for i in range(n-1):
  x=list(map(int,input().split()))
  x=x[1:]
  for j in a:
    if j not in x:
      a.remove(j)
print(len(a))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.pop(0)
for i in range(n-1):
  x=list(map(int,input().split()))
  x.pop(0)
  for j in a:
    if j not in x:
      a.remove(j)
print(len(a))

Submission status: Wrong Answer

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

c = [0] * (m+1)

for i in k:
  for j,data in enumerate(i):
    if j == 0:
      continue
    else:
      c[data] += 1

ans = 0
for i in c:
  if i == 3:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
n,m=map(int,input().split())
s=list(input().split() for i in range(n))
l=[]
c=0
for j in range(n):
    l.append(s[j][1:])
l=list(itertools.chain.from_iterable(l))    

for i in range(1,m+1):
    if l.count('i')==n:
        c+=1
print(c)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.pop(0)

if N>1:
    for _ in range(N-1):
        B=list(map(int,input().split()))
        for num in A:
           if num not in B[1:]:
               A.remove(num)

print(len(A))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.pop(0)
for _ in range(N-1):
    B=list(map(int,input().split()))
    for num in A:
        if num not in B[1:]:
            A.remove(num)

print(len(A))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.pop(0)
for _ in range(N-1):
    B=list(map(int,input().split()))
    for num in A[1:]:
        if num not in B:
            A.remove(num)

print(len(A))

Submission status: Wrong Answer

Solution code:
n, m  = map(int,input().split())
ans = set(list(range(1, m+1)))
for i in range(n):
  k, *a = map(int, input().split())
  ans &= set(a)
  
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
ka = [list(map(int,input().split())) for _ in range(n)]
for i in ka:
    del(i[0])
flag_1 = False
count = 0
for i in range(1,m):
    for j in ka:
        if j.count(i) >= 1:
            flag_1 = True
        else:
            flag_1 = False
            break
    if flag_1:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ll0 = list(map(int, input().split()))
lt = ll0[1:]
ll = [list(map(int, input().split())) for _ in range(n-1)]
for l in ll:
    for i in lt:
        if  i in l[1:]:
            pass
        else:
            lt.remove(i)
print(len(lt))

Submission status: Wrong Answer

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

for i in range(0,n):
  a[i] = input().split()
  k[i] = a[i][0]
  del a[i][0]

l = a[0]
#print(l)
for i in range(1,n):
  if(len(l) == 0):
    #print(0)
    exit()
  else:
    for j in l:
      if(j not in a[i]):
        k = l.index(j)
        del l[k]
            
print(len(l))

Submission status: Wrong Answer

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

d = dict()
for i in range(n):
  a,*b = list(map(int,input().split()))
  d[i] = b

x = 0
ans = 0
for j in range(1,m+1):
  for i in range(n):
    if j in d[i]:
      x += 1
    else:
      x = 0
      break
  if x == n:
    ans += 1

print(ans)

Submission status: Wrong Answer

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


print(a.count(n))

Submission status: Wrong Answer

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

A = list(map(int,input().split()))
A.pop(0)
n = 1

while (len(A) > 0) and (n<N ):
    K = list(map(int,input().split()))
    n +=1
    for i in A:
        if i not in K[1:]:
            A.remove(i)

print(len(A))

Submission status: Wrong Answer

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

A = list(map(int,input().split()))
n = 1

while (len(A) > 1) and (n<N ):
    K = list(map(int,input().split()))
    n +=1
    for i in A[1:]:
        if i not in K[1:]:
            A.remove(i)

print(len(A)-1)

Submission status: Wrong Answer

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

for _ in range(n):
    A = list(map(int, input().split()))
    for a in A[1:]:
        check[a-1] += 1
        print(check)

ans = sum([c == n for c in check])
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
k = []
for i in range(n):
    k.append(list(map(int, input().split())))
    k[i].pop(0)
ans = 0
cnt = 0
for i in k:
    for j in i:
        if j in i:
            cnt += 1
    if cnt == n:
        ans += 1
    cnt = 0
if n == 1:
    print(len(k[0]))
    exit(0)
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
n,m=map(int,input().split())
a=[]
for i in range(0,n):
  a.append(list(map(int,input().split())))
  del a[i][0]
a=list(itertools.chain.from_iterable(a))
count=0
for i in range(0,m):
  if a.count(i)==n:
    count=count+1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
N,M=map(int, input().split())
res=[]
for _ in range(N):
  data=list(map(int, input().split()))
  K=data.pop(0)
  A=data
  res.append(A)
print(res)
flatten_list = list(itertools.chain.from_iterable(res))
cnt=0
for i in range(1, M+1):
  if flatten_list.count(i) == N:
    cnt +=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m = map(int, input().split())
k = [0] * n
for i in range(n):
    k[i] = list(map(int, input().split()))
b = np.zeros((n, m))
for i in range(n):
    w = k[i]
    for j in range(len(w)):
        b[i, int(w[j])-1] = 1
print(sum(b.sum(axis=0) == n))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
li = []
for i in range(n):
    ka = list(map(int,input().split()))
    li.extend(ka[1:])
ans = 0
for i in range(m):
    if li.count(i) == n:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ka = [0]*n
L = []
for i in range(n):
    ka = list(map(int,input().split()))
    L += ka[1:]
    if n == 1:
        L += ka[1:]
dup = [x for x in set(L) if L.count(x) == 3]
print(len(dup))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
n_list = list(map(int,input().split()))[1:]

for i in range(a-1):
  n_list = set(n_list) ^ set(list(map(int,input().split()))[1:])
  
print(len(n_list))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
f=list(map(int,input().split()))
f.remove(f[0])
for i in range(n-1):
    a=list(map(int,input().split()))
    a.remove(a[0])
    for j in f:
        if j  not in a:
            f.remove(j)
print(len(f))

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a-1] = 1
    count = 0
    for j in range(1, M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
judge = [i for i in range(1, m+1)]
for i in range(n):
    a = list(map(int, input().split()))
    a.pop(0)
    for j in judge:
        if not j in a:
            judge.remove(j)
print(len(judge))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k0 = list(map(int, input().split()))
k0.pop(0)
le = len(k0)
aut = []

for i in range(n-1):
    ka = list(map(int, input().split()))
    ka.pop(0)
    for j in range(le):
        num = k0[j]
        if num not in ka:
            aut.append(num)

print(le-len(aut))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
y=0
if n!=1:
    for i in range(m):
        x=0
        for j in range(n):
            print(a[j][1:a[j][0]+1])
            if i+1 in a[j][1:a[j][0]+1]:
                x+=1
                print(x)
            else:
                x+=0
                print(x)
        if x==n:
            y+=1
    print(y)
else:
    for i in range(2,a[0][0]+1):
        if a[0][1]!=a[0][i]:
            y+=1
    print(y+1)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
y=0
if n!=1:
    for i in range(1,m+1):
        x=0
        for j in range(n):
            for k in range(1,a[j][0]+1):
                if str(i) in str(a[j][k]):
                    x+=1
        if x==n:
            y+=1
    print(y)

else:
    z=0
    for i in range(1,a[0][0]-1):
        for j in range(i+1,a[0][0]):
            if a[0][i]==a[0][j]:
                z+=1
                break

    print(a[0][0]-z)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
y=0
if n!=1:
    for i in range(1,n+1):
        x=0
        for j in range(n):
            for k in range(1,a[j][0]+1):
                if str(i) in str(a[j][k]):
                    x+=1
        if x==n:
            y+=1
    print(y)

else:
    z=0
    for i in range(1,a[0][0]-1):
        for j in range(i+1,a[0][0]):
            if a[0][i]==a[0][j]:
                z+=1
                break

    print(a[0][0]-z)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
y=0
if n!=1:
    for i in range(1,n+1):
        x=0
        for j in range(n):
            for k in range(1,a[j][0]+1):
                if str(i) in str(a[j][k]):
                    x+=1
        if x==n:
            y+=1
    print(y)

else:
    print(a[0][0])

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
ans = [1]*m

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

print(ans.count(1))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
ans = [1]*m

for i in range(n):
    x = list(map(int,input().split()))
    x.pop(0)
    for j in range(m):
        if j not in x:
            ans[j-1] = 0

print(ans.count(1))

Submission status: Wrong Answer

Solution code:
#ABC-118-B
N, M = map(int, input().split())
memo = [0]*(M+1)

for _ in range(N):
    Ki, *A = map(int, input().split())
    for item in A:
        memo[int(item)] += 1

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

Submission status: Wrong Answer

Solution code:
import collections
n, m = map(int, input().split())
a_list = sum([list(map(int, input().split()))[1:] for _ in range(n)], [])
col = collections.Counter(a_list)
print(sum([k for k, v in col.items() if v == n]))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(N)]
m = []
for i in range(1, l[0][0] + 1):
    m.append(l[0][i])
for i in range(1, N):
    for j in m:
        
        if l[i][1:l[i][0] + 1].count(j) == 0:
            m.remove(j)
            
print(len(m))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
l = [list(map(int, input().split())) for i in range(N)]
m = []
for i in range(1, l[0][0] + 1):
    m.append(l[0][i])
for i in range(1, N):
    for j in m:
        
        if l[i][1:].count(j) == 0:
            m.remove(j)
            
print(len(m))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ka = []
cnt = 0
ans = 0
for i in range(n):
    ka_memo = list(map(int, input().split()))
    ka_memo.sort()
    ka.append(ka_memo)

for i in range(1, m + 1):
    cnt = 0
    for j in range(n):
        for k in range(1, ka[j][0] + 1):
            if ka[j][k] == i:
                cnt += 1
        if cnt == n:
            ans += 1

print(ans)

Submission status: Wrong Answer

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

for i in range(N-1):
    a = set(l[i])&set(l[i+1])
    l[i+1] = a
    if N==1:
       print(len(l[0])) 
    print(len(a))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
l = [list(map(int,input().split())) for i
     in range(N)]
for i in range(N):
  del l[i][0]
if N!=1:
  for i in range(N-1):
    a = set(l[i])&set(l[i+1])
    l[i+1] = a
    print(len(a))
else:
  print(len(l))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
l = [list(map(int,input().split())) for i
     in range(N)]
del l[0:N][0]
#print(l)
sum = []
for i in range(N-1):
  sum += list(set(l[i])&set(l[i+1]))

print(len(sum))

Submission status: Wrong Answer

Solution code:
#ABC118

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

Submission status: Wrong Answer

Solution code:
#ABC118

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
K, A = [0] * N, [0] * N
for i in range(N):
    K[i], *A[i] = set(map(int, input().split()))
k = set(i for i in range(1, M + 1))
for j in range(N):
    k = k.intersection(A[j])
print(len(k))

Submission status: Wrong Answer

Solution code:
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = [[int(i) for i in input().split()] for _ in range(n)]
k=[]
ans = 0

for i in range(n):
  k.append(a[i][0])

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

print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
c = list(map(int, input().split()))
A = set(c[1:])
for i in range(n-1):
	t = list(map(int, input().split()))
	A ^= set((t[1:]))
print(len(A))

Submission status: Wrong Answer

Solution code:
import collections

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=[0]*(M+1)
cnt=0
for i in range(N):
  S=list(map(int,input().split()))
  for j in range(1,S[0]+1):
    A[S[j]]+=1
    #print(A)
print(A)
for i in range(len(A)):
  if A[i]>=N:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,m = [int(x) for x in input().split()]
lst = []
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    lst.append(tmp)

ansset = set(lst[0][1:])

for i in range(1,n):
    tmpset = set(lst[i][1:])
    ansset = (ansset ^ tmpset)

print(len(ansset))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
list=[]
s=set(range(1, M+1))
for i in range(N):
    list.append(input().split())
    s &= set(list[1:])
    list=[]
print(len(s))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
list=[]
s=[]
if N == 1:
    a, *b=map(int, input().split())
    print(a)
else:
    for i in range(N):
        list.append(input().split())
        s = set(s) & set(list[1:])
        list=[]
    print(len(s))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
list=[]
s=[]
if N == 1:
    print(len(input())-1)
else:
    for i in range(N):
        list.append(input().split())
        s = set(s) & set(list[1:])
        list=[]
    print(len(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
L=[[int(i) for i in input().split()][1:] for j in range(N)]
#print(L)
cnt=0
for i in range(1,M+1):
  for j in range(N):
    #print(L[i][1:])
    if i in L[j]:
      break
  else:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
c = [0] * m
for i in range(n):
    k, *a = map(int, input().split())
    print(a)
    for e in a:
        c[e-1] += 1

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

print(ans)

Submission status: Wrong Answer

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

for i in range(n):
    liked = list(map(int, input().split()))
    for j in range(liked[0]):
        liked[j+1] += 1
seq.count(n)