1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
k, n_1 = [int(x) for x in input().split(" ")]
meeting_arr = [[0] * n_1]

for n in range(1, k):
    meeting_arr.append([int(n) for n in input().split(" ")][1:])

current_day = [1] * len(meeting_arr[-1])
min_attendees = sum(current_day)

for n in range(k - 1, 0, -1):
    # placeholder for the previous day
    previous_day = [0] * len(meeting_arr[n - 1])

    # checks all meetings of a given day
    for j in range(0, len(meeting_arr[n])):
        a = meeting_arr[n][j]
        # if the meeting is a continuation of a previous meeting, add people from that meeting
        if (a > 0):
            previous_day[a - 1] += current_day[j]
    # sum attendees of the previous day
    previous_day = [x or 1 for x in previous_day]
    previous_day_sum = sum(previous_day)
    if previous_day_sum > min_attendees:
        min_attendees = previous_day_sum
    current_day = previous_day

print(min_attendees)