Under construction

Still being built. Things may change

Gahee and the Chaos Papulatus

Time limit1sMemory limit512 MB

Summary
Given the clock time, zone percentages, and timed item and seal events, find the HP percentage Papulatus recovers when the pattern ends.
Level

Easy3 of 10

Topics
Simulation, Implementation, Math
Solved
No attempts yet

Problem

Papulatus is a boss in MapleStory.

Among the patterns Papulatus uses is the Dimensional Crack Seal pattern. When it is cast, Papulatus's clock appears, divided into 6 zones.

[Figure 1] Papulatus's clock

The hour hand is in zone 1 when it points between 12 and 2 o'clock, zone 2 between 2 and 4, zone 3 between 4 and 6, zone 4 between 6 and 8, zone 5 between 8 and 10, and zone 6 between 10 and 12. Cases where the hour hand points exactly at 2, 4, 6, 8, 10, or 12 o'clock are not considered.

In Figure 1, the hour hand is in zone 6. The clock reads about 11:55, and the hour hand points between 10 and 12.

[Figure 2] Items that change the time shown on Papulatus's clock

By eating an item, Gahee can advance the time shown on Papulatus's clock by a set amount. For example, if the clock shows 11:55 and she eats a 10MIN item, the clock advances 10 minutes to 12:05.

[Figure 3] A clock with zones 1, 2, 5, and 6 sealed

When the hour hand is in zone x and the player presses the up key on the left portal of the clock, zone x is sealed. One minute after the pattern is cast, if any zones remain unsealed, Papulatus recovers HP equal to the sum of the % values written in those zones. If the sum exceeds 100, Papulatus recovers 100%. If all 6 zones are sealed before the minute passes, the pattern ends regardless of the remaining time.

Given the events Gahee performed after the Dimensional Crack pattern was cast, find the percentage of HP Papulatus can recover when the pattern ends.

Input

The first line contains the time shown on Papulatus's clock when the Dimensional Crack pattern is cast, in the form hh:mm.

The second line contains the numbers written in zones 1 through 6, separated by spaces.

The third line contains the number of events L.

The next L lines list the events in chronological order. Each event has one of the following formats.

  • s.T ^
    • At game time s.T seconds, Gahee presses the up key on the left portal of the clock.
  • s.T 10MIN
    • At game time s.T seconds, Gahee eats a 10MIN item.
  • s.T 30MIN
    • At game time s.T seconds, Gahee eats a 30MIN item.
  • s.T 50MIN
    • At game time s.T seconds, Gahee eats a 50MIN item.
  • s.T 2HOUR
    • At game time s.T seconds, Gahee eats a 2HOUR item.
  • s.T 4HOUR
    • At game time s.T seconds, Gahee eats a 4HOUR item.
  • s.T 9HOUR
    • At game time s.T seconds, Gahee eats a 9HOUR item.

In the s.T format, s is an integer of 0 or more, and T is an integer from 0 to 999. If T has two digits, a 0 is placed before it. If T has one digit, 00 is placed before it. The event happens at game time s+T×10−3s + T \times 10^{-3} seconds.

Output

Print h, the percentage of HP that Papulatus recovers after the Dimensional Crack pattern ends.

Constraints

  • 1≤L≤1501 \le L \le 150
  • Other patterns (such as the pincer pattern or the laser pattern) are ignored.
  • In the hh:mm format, hh is an integer from 0 to 11, and mm is an integer from 0 to 59. If hh or mm is less than 10, a 0 is placed before it. mm is never a multiple of 10.
  • No two events occur at the same time, and events are given in chronological order.
  • No events are given after the Dimensional Crack seal pattern ends.
  • Each number written in a clock zone is 1, 10, or 100.

Examples2

  1. Example 1

    Input
    10:13
    10 10 10 10 10 100
    1
    0.101 ^
    
    Expected output
    50
    
  2. Example 2

    Input
    10:13
    1 10 10 10 10 100
    3
    0.101 ^
    2.333 2HOUR
    4.444 ^
    
    Expected output
    40