CF2024A.Profitable Interest Rate

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Profitable Interest Rate

Alice has aa coins. She can open a bank deposit called "Profitable", but the minimum amount required to open this deposit is bb coins.

There is also a deposit called "Unprofitable", which can be opened with any amount of coins. Alice noticed that if she opens the "Unprofitable" deposit with xx coins, the minimum amount required to open the "Profitable" deposit decreases by 2x2x coins. However, these coins cannot later be deposited into the "Profitable" deposit.

Help Alice determine the maximum number of coins she can deposit into the "Profitable" deposit if she first deposits some amount of coins (possibly 00) into the "Unprofitable" deposit. If Alice can never open the "Profitable" deposit, output 00.

Input

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

A single line of each test case contains two integers aa and bb (1a,b1091 \le a, b \le 10^9) — the number of coins Alice has and the initial minimum amount required to open the "Profitable" deposit.

Output

For each test case, output a single integer — the maximum number of coins that Alice can deposit into the "Profitable" deposit. If Alice can never open the "Profitable" deposit, output 00.

Note

In the first test case, aba \ge b, so Alice can immediately open the "Profitable" deposit with all 1010 coins.

In the second test case, Alice can open the "Unprofitable" deposit with 22 coins. Then she will have 55 coins left, but the minimum amount required to open the "Profitable" deposit will decrease by 44 coins, making it equal to 55 coins. Thus, Alice will be able to open the "Profitable" deposit with 55 coins.

In the third test case, Alice will not be able to open the "Profitable" deposit.

Samples

5
10 5
7 9
5 100
1 1
1 2
10
5
0
1
0

在线编程 IDE

建议全屏模式获得最佳体验