Sam Slacker is a quintessential slacker. His Short List of activities worth participating in includes video games, eating, and sleeping . . . and not much else. Despite the technological advances of the 2030s, many video games can be classified in the same genres introduced in the 20th century, and Sam's favourite game at the moment is a platformer entitled Super Vinnie.
Super Vinnie has extremely simplistic (yet addictive) gameplay, and while Sam enjoys playing it, he has figured out that he can have the best of two worlds: by writing a program to play the game for him, he can eat or sleep while his program plays the game. Now all he needs to figure out is a way to eat while sleeping . . .
Description:
The levels in Super Vinnie are very simple. Each one consists of ten locations. Every odd location, starting with the first, is empty (and represented by a period, like so: .). Every even location in the level contains either an enemy (represented by the capital letter E) or a coin (represented by the capital letter C). Vinnie starts off in the first (empty) location; his goal is to get past the tenth location, thereby beating the level.
Vinnie starts off every level with some amount of health h in health points. If he ever finds himself at 0 health points or below, he dies and does not complete the level. The value of h at the start of any level satisfies the statement 0 <= h <= 3, and 3 is the maximum number of health points that Vinnie can have.
The game pad used to play Super Vinnie has two buttons, A and B. Vinnie is constantly running from left to right, and each action moves him two spaces--either into the next empty location, or past the tenth location. If A is pressed, Vinnie will jump. If there is a coin in the location between where he jumps and where he lands, he will pick it up; if there is an enemy, he will leap over the enemy, unharmed. If B is pressed, Vinnie will attempt a slide attack. If he slides and there is a coin in the intervening space, he does not pick it up. If there is an enemy there, the attack is only successful if Vinnie is at full strength (3). If he is at full strength, he defeats the enemy and moves on, taking no damage. If he is not at full strength, he still manages to pass the enemy, but he takes one point of damage. Sometimes Sam (or the program he wrote, which has inherited much of Sam's attitude towards productivity) decides to stop pressing any buttons, in which case Vinnie runs blindly through the rest of the level, missing any coins and taking one point of damage from each remaining enemy. Assume that if there are less than 5 button presses, they apply in order--the first button press (if it occurs) cooresponds to moving from location 1 to 3, the second button press (if it occurs) cooresponds to moving from location 3 to 5, and so on.
The number of button presses for a given level, n, satisfies the statement 0 <= n <= 5.
Note that n is not given in the data file.
Input:
The first piece of data in the file is the number of levels that the computer must control Vinnie through, represented by a non-negative integer. For each level, the first line contains a single integer h, Vinnie's starting health for that level. The next line is a representation of that level, using the characters shown above with no spaces in-between and starting at the first location. The second line is a series of n button presses; each press comes from the set {A, B} and has no spaces in-between.
Output:
For each level, print
Level x:where x is the level number, starting from 1. Then, if Vinnie made it past the level, print
SUCCESS Health: s Coins: cwhere s is the number of health points he has at the end of the level and c is the number of coins he collected in the level. If he died at some point in the level, print
DEATH Location: e Coins: cwhere e is the location of the enemy that killed him and c is the number of coins he collected in the level.
Sample Input:
3 Number of levels that the computer must play 2 Starting health for level one .C.E.E.C.E Representation of level one AAABB Button presses for level one 3 Starting health for level two .E.E.E.C.C Representation of level two BBAAA Button presses for level two 1 Starting health for level three .E.E.C.C.C Representation of level three A Button presses for level three
Sample Output:
Level 1: SUCCESS Health: 1 Coins: 1 Level 2: SUCCESS Health: 3 Coins: 2 Level 3: DEATH Location: 4 Coins: 0