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: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

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

#### START
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:

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()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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])):
        #print(i)
        #print(j)
        C[A[i][j]]+=1
co=0
for i in range(m+1):
    if C[i]==n :
        co+=1
print(co)

Submission status: Accepted

Solution code:
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])))

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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
    #(food)
print(len(food))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
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
"""
a,b = LI()
if b % a == 0:
    print(a+b)
else:
    print(b-a)
"""

#B
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)
#C
"""
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)
"""

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!venv/bin/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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8


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()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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(foods)
    print(len(foods))


def main():
    solve()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m = map(int,input().split())
d = defaultdict(int)
for i in range(n):
    a = list(map(int,input().split()))
    for i in range(a[0]):
        d[a[i+1]] += 1
ans = 0
for k,v in d.items():
    if v==n:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from itertools import permutations
def  inpl(): return list(map(int, input().split()))

N, M = inpl()
OK = [0]*(M+1)

for i in range(N):
    for a in inpl()[1:]:
        OK[a] += 1
print(sum([ok == N for ok in OK]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
s = set([i for i in range(1, M + 1)])
for i in range(N):
    A = list(map(int, input().split()))
    A = A[1: ]
    for j in range(1, M + 1):
        if j not in A and j in s:
            s.remove(j)

print(len(s))

Submission status: Accepted

Solution code:
N, M = (int(i) for i in input().split())
L = [0] * M
for i in range(N):
    A = [int(i) for i in input().split()]
    A = A[1:]
    for a in A:
        L[a-1] += 1
aa = 0
for l in L:
    if l == N:
        aa += 1
print(aa)

Submission status: Accepted

Solution code:
from collections import Counter
c = Counter()
cnt = 0
N,M = map(int,input().split())
for i in range(N):
    src = list(map(int,input().split()))
    for j in src[1:]:
        c[j] += 1

for i in c:
    if c[i] == N:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
bit = [0]*M
for i in range(N):
    info = list(map(int,input().split()))[1:]
    for e in info:
        bit[e-1] += 1
cnt = 0
for b in bit:
    if b == N:
        cnt +=1
print(cnt)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
data=[0 for k in range(m)]
for i in range(n):
    x=list(map(int,input().split()))
    for j in range(x[0]):
        data[x[j+1]-1]+=1
print(data.count(n))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()
vote = [0]*(m+1)
for _ in range(n):
    like = list(li())
    
    for i in like[1:]:
        vote[i] += 1
        
ans = 0
for vi in vote:
    if vi == n:
        ans += 1
        
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
from collections import defaultdict
g = defaultdict(int)
for i in range(N):
    l = list(map(int, input().split()))
    for j in range(1, l[0]+1):
        g[l[j]] += 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N, M = map(int, input().split())

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

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

    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = map(int, raw_input().split())
f = [0 for i in xrange(m+1)]
for i in xrange(n):
	a = map(int, raw_input().split())
	for j in xrange(1,len(a)):
		f[a[j]] += 1
ans = 0
for i in xrange(1,m+1):
	if f[i] == n:
		ans += 1
print ans

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
N,M = map(int, input().split())

L = [0]*(M+1)

for i in range(N):
    x = list(map(int, input().split()))
    # k = x[0]
    A = x[1:]
    for a in A:
        L[a] += 1

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

Submission status: Accepted

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

FOOD=[0]*(M+1)

for i in range(N):
    for l in LIKE[i][1:]:
        FOOD[l]+=1

ANS=0
for f in FOOD:
    if f==N:
        ANS+=1

print(ANS)

Submission status: Accepted

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


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

print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

aset = None

for _ in range(n):
  alist = list(map(int, input().strip().split()))[1:]
  if aset is None:
    aset = set(alist)
  else:
    aset = aset.intersection(set(alist))
print(len(aset))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
d=[0 for i in range(m)]
for i in range(n):
    x=list(map(int,input().split()))
    for j in range(1,x[0]+1):
        d[x[j]-1]+=1

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

Submission status: Accepted

Solution code:
N, M =map(int, input().split())
k_list = []
items = []
for i in range(N):
    tmp = tuple(map(int, input().split()))
    k_list.append(tmp[0])
    items.append(tmp[1:])

ans = set(items[0])

for i in range(1, N):
    item = items[i]
    item = set(item)
    ans = ans & item

print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

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

n, m = [int(x) for x in input().split()]
foods = set(range(m + 1))
for _ in range(n):
    foods = foods & set([int(x) for x in input().split()][1:])
print(len(foods))

Submission status: Accepted

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

ms = [0 for i in range(M)]
for a_s in A:
    for a in a_s:
        ms[a - 1] += 1
ans = 0
for m in ms:
    if m == N:
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]
ctr = Counter()
for row in src:
    ctr += Counter(row[1:])

ans = 0
for v in ctr.values():
    if v==N:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)

n,m = map(int,input().split())
l = []
for i in range(n):
    p = list(map(int,input().split()))
    l += p[1:]
g = gb(sorted(l))
res = 0
for k,v in g:
    q = len(list(v))
    if (q == n):
        res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, raw_input().split())
ans = [0 for _ in xrange(M+1)]

for _ in xrange(N):
    A = map(int, raw_input().split())[1:]
    for a in A:
        ans[a] += 1

a = 0

for b in ans:
    if b == N:
        a += 1

print a

Submission status: Accepted

Solution code:
N,M = map(int, raw_input().split())
C = [0]*M
for i in range(N):
  A = map(int, raw_input().split())
  for a in A[1:]:
    C[a-1] += 1
print C.count(N)

Submission status: Runtime Error

Solution code:

N, M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
x = 0
for i in range(M+1):
    x += i
ct = 0
for j in range(N):
    if (sum(A[j])-A[j][0]) == x
    ct += 1
print(ct)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
b=[]
s=[0]*M
for i in range(N):
    a=list(map(int,input().split()))
    del a[0]
    a.sort()
    b.append(a)
for i in range(N):
    for j in range(len(b[i])):
        s[b[i][j]]+=1
print(s.count(N))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
t = [0 for i in range(M+1)]
for i in range(N):
  A = map(int, input().split())
  for j in range(1, A[0]+1):
    t[ A[j] ] += 1
ans = 0
for i in t:
  if i == N:
    ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

cnt=0
for j in foods:
  if j==N:
    cnt+=1

print(cnt)

Submission status: Runtime Error

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

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

cnt=0
for j in foods:
  if j==N:
    cnt+=1

print(cnt)

Submission status: Runtime Error

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

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


  for a in KA[1:]:
    foods[a-1]+=1

cnt=0
for j in foods:
  if j==N:
    cnt+=1

print(cnt)

Submission status: Runtime Error

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

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


for a in KA[1:]:
  foods[a-1]+=1

cnt=0
for j in foods:
  if j==N:
    cnt+=1

print(cnt)

Submission status: Runtime Error

Solution code:
N,P = map(int,input().split())
List=[]
for i in range(N):
    List+=list(map(int,input().split()))
count = 0
for i in range(P+1):
  if List.count(List[i])=N:
    count +=1
print(count)

Submission status: Runtime Error

Solution code:
import sys

n,m=map(int,input().split())
ans=[]*(m+1)
output=0

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

for i in ans:
    if ans[i]==n:
        output+=1

print(output)

Submission status: Runtime Error

Solution code:
import sys

n,m=map(int,input().split())
ans=[0]*(m+1)
output=0

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

for i in ans:
    if ans[i]==n:
        output+=1

print(output)

Submission status: Runtime Error

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

cnt = [0]*m

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
/

Submission status: Runtime Error

Solution code:
。

Submission status: Runtime Error

Solution code:
ｌ

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

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

for c in C:
    if c == N:
        count += 1

print(count)

Submission status: Runtime Error

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

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

print(len(LIKE))

Submission status: Runtime Error

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: Runtime Error

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 == 1:
        s = set(list(a))
    else:
        _s = set(list(a))
    s &= _s

print(len(s))

Submission status: Runtime Error

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)]
    print(a)
    if i == 1:
        s = set(list(a))
    else:
        _s = set(list(a))
    s &= _s

print(len(s))

Submission status: Runtime Error

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[i, 0:len(a)] = a

A = A[(A != 0) & (A < M)]
len(np.unique(A))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
K = []
sum = 0
if N==1:
  W=list(map(int,input().split()))
  W.pop(0)
  K+=W
  print(len(K))
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: Runtime Error

Solution code:
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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# N：人数 M：種類
# K1：個 A1 A2 ...：好きな食べ物の数字
# K2 A1 A2
# 全員が好きな食べ物の種類数

N, M = map(int, input().split())
s = set(range(1, M+1))

for _ in range(N):
    k, *a = map(int, input().split())
    if len(s) == 0:
        s = a
    s&=set(a)
print(len(s))