Trip the Lights Fantastic#1192

Trip the Lights Fantastic

2 seconds
32 megabytes
Very easy

Bob Roberts (father of Little Bobby from problem D) works at the Traffic Commission for a medium-sized town. Bob is in charge of monitoring the traffic lights in the city and dispatching repair crews when necessary. Needless to say, Bob has a lot of free time, so to while away the hours, he tries to figure out the quickest way to take short trips between various points in the city. Bob has at his disposal a lot of information: the layout of the streets in the city and the location and cycle times for all of the traffic lights. To simplify the solution process, he makes the following assumptions:

  1. All cars travel at the same top speed, and, if sitting at a red light, take seconds to react and get up to speed. (That is, Bob assumes the car is essentially standing still for seconds, then proceeds at top speed. Bob also assumes the light will not have turned back to red in the seconds it takes to get going.)

  2. Each car approaches a light at full speed and either passes through the light if it is green or yellow, or comes to an immediate stop if it is red. Cars are allowed to pass through a light if they hit it just as it is turning to green. Cars must stop if they reach the light just as it is turning to red.

  3. The time to make turns through a light is ignored. It is possible to travel between any two lights, although perhaps not directly.

Furthermore, no U-turns are allowed, nor will routes revisit an intersection. Even given these assumptions, Bob has difficulty coming up with minimum time paths. Let's see if you can help him.

Input

The first line of each test case will contain four positive integers , , , and , where (2 \leq n \leq 100) is the number of traffic lights (numbered through n - 1), is the number of roads between the traffic lights, and and (s \ne e) are the starting and ending lights for the desired trip.

There will then follow lines of the form g\ y\ r indicating the number of seconds that each light is green, then yellow, then red. (1 \leq g,y,r \leq 100.) The first of these lines refers to light , the second to light , and so on.

Following these lines will be lines, each describing one road. These lines will have the form l_1\ l_2\ t, where l_1 and l_2 are the two lights being connected by the road, and is the time (in seconds, t \leq 500) to travel the length of the road at full speed — you should add to this value to obtain the travel time when driving the road beginning at a standstill. All roads are two-way.

At time , all lights are just starting their green period, and your car is considered to be at a standstill at traffic light . Since it takes seconds to get going, you may assume that g + y is never less than or equal to . The last test case is followed by a line containing indicating end-of-input.

Output

For each test case, output a single line containing the minimum time to travel from the start light to the end light. Output your results in the form mm:ss indicating the number of minutes and seconds the trip takes. If the number of seconds is less than then preface it with a (i.e., output 4:05, not 4:5). Likewise, if the number of minutes is less than , print just one digit (as in 4:05).

Examples

Example 1

Loading
Loading