You have a suitcase with length $X$, width $Y$ and height $Z$. You also have a very comfortable blanket. It has length $L$, width $W$and thickness $H$. You love your blanket very much. You like to take it with you, wherever you go. To fit the blanket in your suitcase, you can apply a fold operation on the blanket.
One fold operation is as follows:
Divide the length or width by $2$.
Multiply the thickness by $2$.
The blanket fits if you can keep it in the suitcase in an axis aligned way. Formally, at least one corner of the blanket must exactly coincide with a corner of the suitcase keeping the entire blanket inside.
Your task is to find the minimum number of fold operations required to fit the blanket in the suitcase. Or report if it is impossible.
Note that it is not necessary to keep the suitcase in input orientation of $X$ * $Y$ * $Z$, as long as the orientation is axis aligned.
The first line contains an integer $T( 1 \leq T \leq 10^5)$ the number of test cases.
Each of the next $T$ lines describe a test case with $6$ space separated integers $X, Y, Z, L, W, H$. Each of these $6$ integers are greater than $0$ and do not exceed $10^9$.
For each test case print a single integer in a separate line.
Print the minimum number of fold required to fit the blanket. If impossible, print $-1$.
Input | Output |
---|---|
4 100 100 100 1600 100 6 100 100 100 1600 100 7 32 1024 2048 4096 16384 1 1000000000 10000 100 98 500000000 9899 | 4 -1 5 0 |
In the first case, you can fold the length $4$ times to obtain $(L, W, H) = (100, 100, 96)$. |