{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\n\u003cem\u003eEarthstone\u003c/em\u003e is a famous online card game created by \u003cem\u003eLizard Entertainment\u003c/em\u003e. It is a collectible card game that revolves around turn-based matches between two opponents. Players start the game with a substantial collection of basic cards, but can gain rarer and more powerful cards through purchasing packs of additional cards, or as rewards for competing in the arena. Card packs can be purchased with gold, an in-game currency rewarded for completing random daily quests and winning matches, or by using real money in the in-game store.\n\u003c/p\u003e\n\n\u003cdiv style\u003d\"text-align: center;\"\u003e\u003cimg src\u003d\"CDN_BASE_URL/b509fb4c6b35e13fe2195b402a7a4135?v\u003d1726147146\"\u003e\u003c/div\u003e\n\n\u003cp\u003e\nEdward is the headmaster of Marjar University. He has lots of money and lots of spare time. Recent days, he was addicted to \u003cem\u003eEarthstone\u003c/em\u003e that he bought over 400 card packs! After having purchased so many cards, he believed that he was invincible. Then, he entered the arena and started a match... Before we continue the story of Edward, let us look at the rules of \u003cem\u003eEarthstone\u003c/em\u003e first.\n\u003c/p\u003e\n\n\u003cp\u003e\nEach \u003cem\u003eEarthstone\u003c/em\u003e battle is a one on one turn-based match between two opponents. During a player\u0027s turn, he can choose to play any of his cards and command the minions to attack targets. Those played cards will be placed on the table as they are \u0027summoned\u0027 as minions. Each card has two basic attributes:\n\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e\u003cul\u003e\n\u003cli\u003eAttack \u003cvar\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e: If a minion attacks a character or was attacked, it will deal \u003cvar\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e points of damage to the opponent. A character whose attack value is zero cannot actively attack.\u003c/li\u003e\n\u003cli\u003eHealth \u003cvar\u003eH\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e: The minion has \u003cvar\u003eH\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e points of initial health. After being damaged, the minion\u0027s health will decrease by the corresponding damage value. The minion will be killed and discarded if its health is less than or equal to zero.\u003c/li\u003e\n\u003c/ul\u003e\u003cp\u003e\u003c/p\u003e\n\n\u003cp\u003e\nIf a minion attacks another minion, both of them will receive damage simultaneously. Besides minions, each player has a hero with some points of initial health. The hero has zero points of attack value and does not have any skills. If a player\u0027s hero is killed, he will lose the game. By the way, the word \u0027character\u0027 in \u003cem\u003eEarthstone\u003c/em\u003e can mean either a hero or a minion.\n\u003c/p\u003e\n\n\u003cp\u003e\nApart from the two basic attributes, minions may have zero or more following abilities:\n\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e\u003cul\u003e\n\u003cli\u003eCharge: A minion cannot actively attack on the same turn that it is summoned, unless it has the Charge ability.\u003c/li\u003e\n\u003cli\u003eDivineShield: Absorbs the first time of non-zero damage taken by the minion, removing the shield.\u003c/li\u003e\n\u003cli\u003eTaunt: Enemies must attack minions with Taunt before any non-Taunt characters.\u003c/li\u003e\n\u003cli\u003eWindfury: During a player\u0027s turn, the player can command all his existing minions or newly summoned Charge minions to attack enemy characters for at most one time. But if a minion has the Windfury ability, it can attack twice instead of once.\u003c/li\u003e\n\u003c/ul\u003e\u003cp\u003e\u003c/p\u003e\n\n\u003cp\u003e\nNow, let us come back to the story of Edward. Edward is playing the game and it is Edward\u0027s turn now. There are already \u003cvar\u003eX\u003c/var\u003e + \u003cvar\u003eY\u003c/var\u003e minions on the table. \u003cvar\u003eX\u003c/var\u003e of them are on the Edward\u0027s side and the other minions are fighting for the opponent. Besides the existing minions, Edward has \u003cvar\u003eZ\u003c/var\u003e cards in his hand. The health of opponent\u0027s hero is \u003cvar\u003eM\u003c/var\u003e. There is no limitation about the number of cards can be played on a turn or the maximal number of minions on the table.\n\u003c/p\u003e\n\n\u003cp\u003e\nEdward is a cautious man, he wants you find out a long-term game strategy about the current situation. You need to reduce the potential damage received on the next turn (the opponent\u0027s turn). The potential damage is defined as the sum of attack value of the opponent\u0027s minions, with Windfury minions count twice. If there are multiple solutions, please find out the solution which can deal as many as possible points of damage to the opponent\u0027s hero. But, Edward will also not miss any chance to win the game. If there exists a strategy to kill the opponent\u0027s hero within the current turn, he will use the winning strategy instead.\n\u003c/p\u003e\n\n\u003ch4\u003eInput\u003c/h4\u003e\n\n\u003cp\u003eThere are multiple test cases. The first line of input contains an integer \u003cvar\u003eT\u003c/var\u003e indicating the number of test cases. For each test case:\u003c/p\u003e\n\n\u003cp\u003e\nThe first line contains 4 integers \u003cvar\u003eX\u003c/var\u003e, \u003cvar\u003eY\u003c/var\u003e, \u003cvar\u003eZ\u003c/var\u003e (0 \u0026lt;\u003d \u003cvar\u003eX\u003c/var\u003e + \u003cvar\u003eZ\u003c/var\u003e \u0026lt;\u003d 8, 0 \u0026lt;\u003d \u003cvar\u003eY\u003c/var\u003e \u0026lt;\u003d 15) and \u003cvar\u003eM\u003c/var\u003e (1 \u0026lt;\u003d \u003cvar\u003eM\u003c/var\u003e \u0026lt;\u003d 100).\n\u003c/p\u003e\n\n\u003cp\u003e\nThe following lines of input consists of 3 parts. These parts have the same input format and contain \u003cvar\u003eX\u003c/var\u003e, \u003cvar\u003eY\u003c/var\u003e, \u003cvar\u003eZ\u003c/var\u003e lines respectively. Each line describes a minion or a card, in the format of \"\u003cvar\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e/\u003cvar\u003eH\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e \u003cvar\u003eabilities\u003c/var\u003e\" (0 \u0026lt;\u003d \u003cvar\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e \u0026lt;\u003d 12, 1 \u0026lt;\u003d \u003cvar\u003eH\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e \u0026lt;\u003d 15). The \u003cvar\u003eabilities\u003c/var\u003e contains zero or more ability names, separated by a space.\n There is no space after \u003cvar\u003eH\u003csub\u003ei\u003c/sub\u003e\u003c/var\u003e if the \u003cvar\u003eabilities\u003c/var\u003e is empty.\u003c/p\u003e\n\n\u003ch4\u003eOutput\u003c/h4\u003e\n\n\u003cp\u003e\nFor each test case, output the minimal potential damage and the maximal damage that Edward can deal to the opponent\u0027s hero.\n\u003c/p\u003e\n\n\u003cp\u003e\nIf the opponent\u0027s hero can be killed within the current turn, output \"Well played\" instead (without quotes).\n\u003c/p\u003e\n\n\u003ch4\u003eSample\u003c/h4\u003e\n\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n2 3 1 30\n2/1 Charge\n9/5\n6/5 Taunt\n4/2 DivineShield Charge\n6/7\n3/5 Windfury Charge DivineShield Taunt\n0 4 1 1\n5/2 Charge\n3/3 DivineShield\n6/7\n4/5 Windfury\n1/1 Charge\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4 3\nWell played\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ch4\u003eHint\u003c/h4\u003e\n\n\u003cp\u003e\nThere are large amount of small test cases and a few number of big test cases.\n\u003c/p\u003e\n"}}]}