Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-

def parse_input():

    
    nm = input().split(" ")
    n = int(nm[0])
    m = int(nm[1])

    rows = []
    for i in range(0, n):
        rows.append([int(e) for e in line.split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):
#            print(rows[i])
            r = rows[i]
#            print(r[1:r[0] + 1])
            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return str(len(result))

def main():

    print(solve(parse_input()))

if __name__ == '__main__':

    main()


# -*- coding: utf-8 -*-

def parse_input():

    
    params = []
    nm = input().split(" ")
    n = int(nm[0])
    m = int(nm[1])
    params.append(n)
    params.append(m)

    for i in range(0, n):
        params.append(input())   

    rows = []
    for line in lines:
        rows.append([int(e) for e in line.split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):
#            print(rows[i])
            r = rows[i]
#            print(r[1:r[0] + 1])
            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return str(len(result))

def main():

    print(solve(parse_input()))

if __name__ == '__main__':

    main()


# -*- coding: utf-8 -*-

def parse_input():

    
    nm = input().split(" ")
    n = int(nm[0])
    m = int(nm[1])

    rows = []
    for i in range(0, n):
        rows.append([int(e) for e in input().split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):
#            print(rows[i])
            r = rows[i]
#            print(r[1:r[0] + 1])
            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return str(len(result))

def main():

    print(solve(parse_input()))

if __name__ == '__main__':

    main()


# -*- coding: utf-8 -*-

import sys
import math

def parse_input(lines_as_string = None):

    lines = []
    if lines_as_string is None:
        for line in sys.stdin:
            lines.append(line)
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    
    nm = lines[0].split(" ")
    n = int(nm[0])
    m = int(nm[1])

    rows = []
    for i in range(1, n+1):
        rows.append([int(e) for e in lines[i].split(" ")])

    return (n, m, rows)

def solve(n, m, rows):

    result = []
    for k in range(1, m + 1):
        tmp = []
        for i in range(0, n):
#            print(rows[i])
            r = rows[i]
#            print(r[1:r[0] + 1])
            if k in r[1:r[0]+1]:
               tmp.append(i+1)
        if len(tmp) == n:
            result.append(k)

    return len(result)

def main():

    print("%d" % solve(*parse_input()))

if __name__ == '__main__':

    main()


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted