H. The Binary Matrix of All Time

Time limit: 1s Memory limit: 256MB Input: Output:

A binary matrix with nn rows and mm columns is considered good if it has no 1×31 \times 3 or 3×13 \times 1 submatrices consisting of equal elements.

For example, [101010101]\begin{bmatrix}1 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 1 \end{bmatrix} and [011110101]\begin{bmatrix}0 & 1 & 1 \\ 1 & 1 & 0 \\ 1 & 0 & 1 \end{bmatrix} are good, while [101101001]\begin{bmatrix}1 & 0 & 1 \\ 1 & 0 & 1 \\ 0 & 0 & 1 \end{bmatrix} and [101000110]\begin{bmatrix}1 & 0 & 1 \\ 0 & 0 & 0 \\ 1 & 1 & 0 \end{bmatrix} are not.

Given two integers nn and mm, what is the maximum number of 11's in a good matrix with nn rows and mm columns?

Input

Each test contains multiple testcases. The first line of input contains one integer tt (1t1051 \le t \le 10^5) — the number of testcases.

The first line of each testcase contains two integers nn and mm (3n,m1093 \le n,m \le 10^9) — the height and width of the matrix.

Output

For each testcase, print one integer, the maximum number of 11's in a good matrix with nn rows and mm columns.

Example

stdin

6
3 3
3 4
126 74
169 208
1000000000 987654320
976875237 848936273

stdout

6
8
6216
23435
658436213333333334
552869881923181134

Log in or sign up to be able to send submissions!