{"raw_statement":[{"iden":"statement","content":"Two powerful magicians “The king of fire” and “The hero of ice” are fighting each other to conquer the world. The winner will be the one who is the smarter and…a bit more successful.\n\nThe fight between two greatest magicians involves a lot of strategy because magicians can cast only limited amount of spells during each moment of time.\n\nYou support the king of fire just because the summer has just ended and you want to swim in the sea and to play volleyball in the beach… Ah, these good summer days! It may be possible again with the power of fire!\n\nEach magician is characterized by _hp_ (health points), _atk_ (the strength of the attack), _def_ (the defence abilities). Each spell is one of the following types: \n\nOpponent loses the dealt damage points from his hp. If player’s hp becomes less than or equal to 0 he is considered dead and his opponent is a winner.\n\nEach player starts with hp = 10, atk = 0, def = 0. Luckily the king of fire moves first. It may increase our chances!\n\nEach player has a sequence of 10 spells. He can reuse the same spell again. During the first turn a magician can use the first 5 spells, during the second - the first 6 spells and so on…During the turn a magician can cast only one spell.\n\nNote: assume that both magicians are very wise and don’t make mistakes, i.e. they play optimally well. It means that a magician tries to minimize the number of turns if it is possible to win. If it is impossible to win, then a magician tries to maximize the number of turns.\n\nNote: it is guaranteed that the winner exists and the game ends in at most 12 turns (that’s it, at most 6 turns for one player).\n\nThe first line contains the number of test cases _T_ (0 ≤ T ≤ 20). The first 10 lines of each test case contain the spells of the king of fire (“_Heal x_”, “_Atk x_”, “_Def x_”, “_HIT!_”), 0 ≤ x ≤ 5. The other 10 lines of each test case contain the spells of the hero of ice (“_Heal x_”, “_Atk x_”, “_Def x_”, “_HIT!_”), 0 ≤ x ≤ 5.\n\nFor each test case output one line containing “_Case #tc: status turn_”, where _tc_ is the number of the test case (starting from 1), _status_ is “win” or “lose” (“win” if the king of fire wins, “lose” otherwise), _turn_ is the turn in which the final hit was made.\n\n"},{"iden":"input","content":"The first line contains the number of test cases _T_ (0 ≤ T ≤ 20). The first 10 lines of each test case contain the spells of the king of fire (“_Heal x_”, “_Atk x_”, “_Def x_”, “_HIT!_”), 0 ≤ x ≤ 5. The other 10 lines of each test case contain the spells of the hero of ice (“_Heal x_”, “_Atk x_”, “_Def x_”, “_HIT!_”), 0 ≤ x ≤ 5."},{"iden":"output","content":"For each test case output one line containing “_Case #tc: status turn_”, where _tc_ is the number of the test case (starting from 1), _status_ is “win” or “lose” (“win” if the king of fire wins, “lose” otherwise), _turn_ is the turn in which the final hit was made."},{"iden":"examples","content":"Input1Atk 5HIT!HIT!HIT!HIT!HIT!HIT!HIT!HIT!HIT!Def 3Def 2Def 2Def 2Def 2Def 2Def 2Def 2Def 2Def 2OutputCase #1: win 11"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases, $ 0 \\leq T \\leq 20 $.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ F_k = (s_{k,1}, \\dots, s_{k,10}) $ be the sequence of 10 spells for the **King of Fire**.  \n- Let $ I_k = (s'_{k,1}, \\dots, s'_{k,10}) $ be the sequence of 10 spells for the **Hero of Ice**.  \nEach spell is one of:  \n- `Heal x`: restores $ x $ HP to caster ($ 0 \\leq x \\leq 5 $)  \n- `Atk x`: increases caster’s attack by $ x $ ($ 0 \\leq x \\leq 5 $)  \n- `Def x`: increases caster’s defense by $ x $ ($ 0 \\leq x \\leq 5 $)  \n- `HIT!`: deals damage equal to caster’s current attack to opponent  \n\nInitial state for both players: $ \\text{hp} = 10 $, $ \\text{atk} = 0 $, $ \\text{def} = 0 $.  \nKing of Fire moves first.  \n\nOn turn $ t \\in \\{1, 2, \\dots, 12\\} $:  \n- The active player can use any of the first $ \\min(5 + \\lceil t/2 \\rceil, 10) $ spells from their sequence.  \n- Only one spell is cast per turn.  \n\n**Constraints**  \n1. Game ends in at most 12 turns.  \n2. A player dies when $ \\text{hp} \\leq 0 $.  \n3. Both players play optimally:  \n   - If a win is possible, minimize the number of turns.  \n   - If a win is impossible, maximize the number of turns.  \n4. Winner is guaranteed to exist.  \n\n**Objective**  \nFor each test case $ k $, determine:  \n- $ \\text{status}_k \\in \\{\\text{win}, \\text{lose}\\} $: whether King of Fire wins.  \n- $ \\text{turn}_k \\in \\{1, \\dots, 12\\} $: the turn on which the final hit was made (i.e., the turn when the opponent’s hp dropped to $ \\leq 0 $).  \n\nOutput: `Case #k: status_k turn_k`","simple_statement":"Two magicians fight: Fire King (goes first) and Ice Hero. Each starts with 10 HP, 0 ATK, 0 DEF. Each has 10 spells, reused in order. On turn n, they can use first (5 + n - 1) spells. Each turn, cast one spell: Heal (add HP), Atk (increase attack), Def (increase defense), or HIT! (deal damage = current ATK). Game ends when one HP ≤ 0. Both play optimally: if they can win, minimize turns; if they can’t win, maximize turns. Game ends in at most 12 turns. Output for each test case: “Case #tc: win/lose turn”.","has_page_source":false}