H. Harvest Moon Rabbits
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The moon drives me crazy

Ugh, the moonlight drives me nuts!

It's such an eyesore!

Alice is volunteering at a magical bunny farm in order to earn some extra credit for her biology class! Magical bunnies are peculiar in that each one can only be in one of three possible states: young, mature, or old.

The farm initially has $$$a$$$ young bunnies, $$$b$$$ mature bunnies, and $$$c$$$ old bunnies. Whenever Alice sacrifices a magical Moon Stone, the following three things happen simultaneously:

  • Half of the young bunnies (rounded down) become mature; the rest die :(
  • Each mature bunny gives birth to $$$3$$$ young bunnies. Then, half of the mature bunnies (rounded down) become old; the rest die :(
  • Each old bunny gives birth to $$$1$$$ young bunny. Then, they all die :(

For her own personal reasons, Alice wants the farm to have $$$d$$$ young bunnies, $$$e$$$ mature bunnies, and $$$f$$$ old bunnies. However, she knows that getting those exact quantities is unlikely. So, she instead settles for aiming to be as close to her target as possible, for some definition of "close".

Suppose that currently, the farm has $$$x$$$ young bunnies, $$$y$$$ mature bunnies, and $$$z$$$ old bunnies. Then, Alice uses the following formula to compute the "square error": $$$$$$\begin{align*} \text{square error} ~ = (x - d)^2 + (y - e)^2 + (z - f)^2. \end{align*}$$$$$$

Find the minimum possible value of the square error, and also the minimum number of magical Moon Stones that Alice needs to sacrifice in order to achieve it.

Also, you must answer $$$T$$$ different test cases.

Input

The first line of input contains a single integer $$$T$$$, the number of test cases.

Then, $$$T$$$ lines follow, each containing the six space-separated integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$, $$$e$$$, and $$$f$$$, corresponding to the values in each test case that must be answered.

$$$$$$\begin{align*}

&\begin{array}{|l|} \hline \text{Constraints For All Subtasks} \\ \hline 1 \leq T \leq 100 \\ 0 \leq a, b, c \leq 100 \\ 0 \leq d, e, f \leq 10^8 \\ \hline \end{array}\\

&\begin{array}{|c|c|l|} \hline \text{Subtask} & \text{Points} & \text{Constraints} \\ \hline

1 & \mathbf{33} & 0 \leq a, b, c \leq 3 \\ && 0 \leq d, e, f \leq 3 \\ \hline

2 & \mathbf{33} & 0 \leq a, b, c \leq 10 \\ \hline

3 & \mathbf{34} & \text{No further constraints.} \\ \hline

\end{array}\\

\end{align*}$$$$$$

Output

Output $$$T$$$ lines. For each test case, output the following two space-separated values.

  • First, the minimum possible square error
  • Then, the minimum number of magical Moon Stones that need to be sacrificed in order to attain this minimum square error
Example
Input
3
1 2 3 6 9 2
3 1 1 9 5 1
1 2 3 4 5 6
Output
4 6
5 6
27 0
Note
  • In the first test case, after sacrificing $$$6$$$ magical Moon Stones, there will be $$$6$$$ young bunnies, $$$9$$$ mature bunnies, and $$$0$$$ old bunnies. This gives a square error of $$$4$$$, which we can show to be minimal.
  • In the second test case, we can show that the minimal square error is $$$5$$$, which is achieved after $$$6$$$ or $$$8$$$ magical Moon Stones. We output $$$6$$$ since that's the smaller of the two and we want to use as few magical Moon Stones as possible.
  • In the third test case, the minimum square error of $$$27$$$ is achieved if Alice just doesn't use any magical Moon Stones at all.