Taxi fares are complicated: they depend on how far you travel, the time of day, and the traffic. A taxi drives through a sequence of streets $S_1, S_2, \dots, S_n$ in this exact order. Street $S_i$ is $L_i$ kilometers long, and the taxi keeps a constant speed on it, taking $M_i$ minutes to drive one kilometer of $S_i$.
A passenger boards at the start of some street $S_i$ and gets off at the end of a later street $S_j$ (boarding and alighting always happen at a street's end, never in the middle of a street). The passenger is charged per kilometer:
Two surcharges may then apply:
The night surcharge is added per kilometer first; the 10% traffic surcharge is then applied once to the resulting total.
The input contains several test cases. Each test case has two parts.
The first part lists the streets the taxi drives through, one per line and in travel order:
street-name length min
Here street-name is a unique string of at most 20 letters and digits with no spaces, length is $L_i$ in kilometers (at most 200), and min is $M_i$ in minutes; both are positive integers. Each street is visited exactly once. This part ends with a line containing only a single $ character.
The second part is one line:
source-street dest-street time
source-street and dest-street are the boarding and alighting street names, and time is the boarding time in 24-hour HH:MM format. Both streets belong to the street list, and the destination street does not come before the source street. A line containing only a single # character ends each test case.
The input ends with a line containing two dash characters --.
For each test case, print a single line containing the fare of the passenger's trip.