#P1987A. Upload More RAM

Upload More RAM

No submission language available for this problem.

Description

Oh no, the ForceCodes servers are running out of memory! Luckily, you can help them out by uploading some of your RAM!

You want to upload nn GBs of RAM. Every second, you will upload either 00 or 11 GB of RAM. However, there is a restriction on your network speed: in any kk consecutive seconds, you can upload only at most 11 GB of RAM in total.

Find the minimum number of seconds needed to upload nn GBs of RAM!

Each test contains multiple test cases. The first line of input contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases. The description of the test cases follows.

The first and only line of each test case contains two integers nn and kk (1n,k1001 \le n, k \le 100) — the number of GBs that you want to upload and the length of the time window respectively.

For each test case, output a single integer — the minimum number of seconds needed to upload nn GBs of RAM.

Input

Each test contains multiple test cases. The first line of input contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases. The description of the test cases follows.

The first and only line of each test case contains two integers nn and kk (1n,k1001 \le n, k \le 100) — the number of GBs that you want to upload and the length of the time window respectively.

Output

For each test case, output a single integer — the minimum number of seconds needed to upload nn GBs of RAM.

Sample Input 1

6
5 1
2 2
2 3
1 7
11 5
100 100

Sample Output 1

5
3
4
1
51
9901

Note

In the first test case, you can upload 11 GB of RAM per second, so to upload 55 GBs, you need 55 seconds.

In the second test case, you can upload 11 GB in the first second, 00 GBs in the second second, and 11 GB in the third second, which in total adds up to exactly 22 GBs of uploaded RAM.

In the third test case, you can upload 11 GB in the first second, 00 GBs in the second second, 00 GBs in the third second, and 11 GB in the fourth second, which in total adds up to exactly 22 GBs of uploaded RAM.