There are 10 LEDs lies horizonally on a building, each LED with length 3600 and have some light spots.
Each second, every LED i shifts from left to right cyclically with its own speed si. You are told the initial position of each light spot, and please tell us the earliest time when exist vertical line all formed by light spots.
Line 1-10: each line first contains two integers, si,di-speed and number of light spots on i`th LED, followed by di integers: c1,c2...c(di), indicate the position of light spots initially(range in [0,3599]).
d1+d2+...+d10 <= 3600
One integer indicate the ealist time when exist vertical line all formed by light spots. If light vertical line does not exist, output a line: "NEVER".