CF2009A.Minimize!

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

Minimize!

You are given two integers aa and bb (aba \leq b). Over all possible integer values of cc (acba \leq c \leq b), find the minimum value of (ca)+(bc)(c - a) + (b - c).

Input

The first line contains tt (1t551 \leq t \leq 55) — the number of test cases.

Each test case contains two integers aa and bb (1ab101 \leq a \leq b \leq 10).

Output

For each test case, output the minimum possible value of (ca)+(bc)(c - a) + (b - c) on a new line.

Note

In the first test case, you can choose c=1c = 1 and obtain an answer of (11)+(21)=1(1 - 1) + (2 - 1) = 1. It can be shown this is the minimum value possible.

In the second test case, you can choose c=6c = 6 and obtain an answer of (63)+(106)=7(6 - 3) + (10 - 6) = 7. It can be shown this is the minimum value possible.

Samples

3
1 2
3 10
5 5
1
7
0

在线编程 IDE

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