You operate the airmail system for a delivery company at one airport, called airport 0. The company runs reception desks and a fleet of planes that fly between airports; a separate ground company handles final delivery once a parcel reaches the airport closest to its address. Each day you must decide which parcels to load onto the planes leaving airport 0.
A day proceeds as follows.
Report, for each flight leaving airport 0, the total value of the parcels loaded onto it.
The input contains several independent loading problems. Each problem begins with a line of five integers $A$ $F$ $P$ $B$ $C$:
The next $A$ lines each contain one integer: the total loading-bay weight at airports $1, 2, \dots, A$, in that order.
The next $F$ lines each describe a flight as three integers $s$ $d$ $c$ — it flies from airport $s$ to airport $d$ carrying up to $c$ kg. Airport $0$ is your airport, and there is at most one flight for each ordered pair of airports. Flights are numbered $0, 1, \dots$ in the order they are given.
The next $P$ lines each describe a customer parcel as a real number $t$ and three integers $w$ $d$ $v$: timestamp $t$, weight $w$ kg, destination airport $d$, and value $v$ dollars. These lines are in increasing timestamp order.
The next $B$ lines describe the parcels already in the loading bay, in the same format and also in increasing timestamp order.
Every value on a line is separated by a single space. The input ends with a line 0 0 0 0 0, which must not be processed.
Constraints: $1 \le A \le 30$, $1 \le F \le 100$, $0 \le P + B \le 5000$, $1 \le C \le 150$.
For each loading problem, and for each flight that leaves airport $0$, print one line in increasing flight-number order, in the form Flight <n> value = <v>, where <n> is the flight's number and <v> is the total value of the parcels loaded onto that flight.