cho.sh
Notes
Loading...

Pet

Time limit

1s

Memory limit

128 MB

Problem

You are caring for a pet in a console game. Depending on its current weight, the pet is happy, sad, or dead.

Each scenario gives the pet's ideal weight o and actual weight w. After all actions in a scenario are processed, the pet is happy if its actual weight is strictly greater than half of the ideal weight and strictly less than twice the ideal weight. If the actual weight becomes 0 or less at any time, the pet dies. In every other case, the pet is sad.

You can perform two kinds of actions on the pet.

  1. E n: exercise the pet for n minutes, decreasing its actual weight by n.
  2. F n: feed the pet by n, increasing its actual weight by n.

For every action, n is an integer from 1 to 999. If the pet dies during a scenario, the remaining actions in that scenario are still read from input, but they no longer affect the pet's weight.

Input

The input consists of several scenarios. Scenarios are numbered from 1 in the order they appear.

Each scenario starts with one line containing the ideal weight o and actual weight w (10 ≤ o, w ≤ 1000). The following lines each contain one action. An action has the form E n or F n, where 1 ≤ n ≤ 999.

A scenario ends with # 0, which must not be processed as an action. The whole input ends with 0 0, which must not be processed.

Output

For each scenario, print one line containing the scenario number and the pet's state after all actions are processed, separated by a space.

  • Print :-) if the pet is happy.
  • Print :-( if the pet is sad.
  • Print RIP if the pet is dead.