1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import math
n=int(input())
ile=[1]+[0]*(n-1)
V=[]
for i in range(n):
    V.append(list(map(int, input().split(' '))))
    if(V[i][0]>0):
        ile[0]*=V[i][0]//math.gcd(ile[i], V[i][0])
        for j in range(1, n):
            ile[j]=0
        for j in range(0, i+1):
            for l in range(1, len(V[j])):
                ile[V[j][l]-1]+=ile[j]//V[j][0]
print(ile[0])