Opening#13087

Opening

2 seconds
256 megabytes

Given two integers and , determine the first element of the funny array with parameters .

Funny array [a_1, a_2, \dots, a_n] with parameters satisfies the following conditions:

Your task is to find the value of a_1 for given and

Input

The first line contains a single integer (1 \le t \le 10^5) — the number of test cases.

Each test case consists of a single line containing two integers and (1 \le n,m \le 10^9) — the length of the array and its common difference.

Output

For each test case, output a single integer — the value of a_1 for the array a = [a_1,a_2,\ldots,a_n].

It can be proved that there is a unique answer.

Examples

Example 1

Loading
Loading

Note

In the first test case, a valid array is a=[1,2,3], and a_3-a_1=3-1=2.

In the second test case, a valid array is a=[4,8,12], and a_3-a_1=12-4=8.

In the third test case, a valid array is a=[4,6,8,10,12], and a_5-a_1=12-4=8.

Scoring

  1. Subtask ( points) : (1 \le n,m \le 10)

  2. Subtask ( points) : No additional constraints