Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets.
A single data set has 3 components:
- Start line - A single line, "START N", where N is the number of buses running and 1 <= N <= 20.
- Route Duration line - There will be N of these lines, and each line will consist of M route durations (where 1 <= M <= 10), which will signify how long it will take each bus to return to the bus station after completing a particular route. A route duration will be represented as an integer between 1 and 1000 (inclusive).
- Arrival Time - There will only be one of these lines per data set. This line represents the time that you arrived at the bus station and began waiting. This is simply the number of time units that you arrived at the bus station after the buses began running (all buses begin running at time 0). This number is represented as a positive integer (yes, it can be 0 as well, this would signify arriving at the bus station as the buses begin running).
- End line - A single line, "END".
Following the final data set will be a single line, "ENDOFINPUT".