We’re preparing your current view and syncing the latest data.
A building has apartments arranged such that each floor contains exactly k apartments. Apartments are numbered consecutively starting from 1 on the ground floor. Given the floor number n (starting from 1) and the apartment's position m on that floor (door number), determine the apartment number.
The first line contains three integers t, k and m where t is the number of test cases. Each of the next t lines contains two integers n and m — the floor and the door number on that floor.
For each test case, output the apartment number corresponding to the given floor n and door number m.
1 ≤ t ≤ 5000 1 ≤ k, m ≤ 10^9 1 ≤ n ≤ 10^9
Example 1
Input
3 3 2 1 1 2 3 3 2
Output
1 6 8
Explanation
For k=3, apartments per floor. Test case 1: Floor 1 door 1 => apartment 1 Test case 2: Floor 2 door 3 => apartment 6 (since floor 2 apartments are 4,5,6) Test case 3: Floor 3 door 2 => apartment 8 (since floor 3 apartments are 7,8,9)