시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 (추가 시간 없음) 256 MB222100.000%

## 문제

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_A$, $HP_B$ and $HP_C$ respectively, and their attack values are $ATK_A$, $ATK_B$ and $ATK_C$ respectively.

During the $i$-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 $i$ (i.e. its health point will be decreased by $i$). That is to say, during the $1$-st second, one of these three monsters will be under an attack of damage $1$, during the $2$-nd second, one of them, if alive, will be under an attack of damage $2$, during the $3$-rd second, one of them, if alive, will be under an attack of damage $3$, 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 $T$ ($1 \le T \le 50$), indicating the number of test cases. For each test case:

The first line contains $6$ integers $HP_A$, $HP_B$, $HP_C$, $ATK_A$, $ATK_B$ and $ATK_C$ ($1 \leq HP_A, HP_B \leq 100$, $1 \leq HP_C \leq 10^{18}$, $1 \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.

## 예제 입력 1

2
1 10 100 3 2 1
3 2 1 1 10 100


## 예제 출력 1

28
123