Fighting Against Monsters

아직 제출이 없습니다시간 제한5초메모리 제한256 MB

문제

One day, a hero and three monsters, one of which is the boss with extremely high health points, are fighting in the forest through turn-based battles. The health points of the three monsters are HP_AHP\_A, HP_BHP\_B and HP_CHP\_C respectively, and their attack values are ATK_AATK\_A, ATK_BATK\_B and ATK_CATK\_C respectively.

During the ii-th second, the hero will be attacked by monsters at first, and the damage is the sum of attack values of all alive monsters. Then he will select exactly one monster which is still alive and attack it. The selected monster will suffer a damage of value ii (i.e. its health point will be decreased by ii). That is to say, during the 11-st second, one of these three monsters will be under an attack of damage 11, during the 22-nd second, one of them, if alive, will be under an attack of damage 22, during the 33-rd second, one of them, if alive, will be under an attack of damage 33, and so on.

Once the health point of a monster is less than or equal to zero, it will die immediately. The hero will win if all the monsters have been killed.

Now you are asked to develop a strategy to minimize the total damages the hero should suffer before he wins the battle.

입력

There are multiple test cases. The first line of the input contains an integer TT (1T501 \le T \le 50), indicating the number of test cases. For each test case:

The first line contains 66 integers HP_AHP\_A, HP_BHP\_B, HP_CHP\_C, ATK_AATK\_A, ATK_BATK\_B and ATK_CATK\_C (1HP_A,HP_B1001 \leq HP\_A, HP\_B \leq 100, 1HP_C10181 \leq HP\_C \leq 10^{18}, 1ATK_A,ATK_B,ATK_C1091 \leq ATK\_A, ATK\_B, ATK\_C \leq 10^9).

출력

For each test case, output an integer denoting the minimal total damages the hero should suffer.