Solve the programming task below in a Python markdown code block.
Chef has a stick of length L. Chef wants to break the stick into K parts such that each part has a non-zero length. 

Let the lengths of the K parts be A_{1}, A_{2}, \ldots, A_{K} (Note that A_{1} + A_{2} + \ldots + A_{K} = L and A_{i} is a positive integer for all i). Chef wants to minimize the value of \displaystyle \sum_{i = 1}^{K - 1}|A_{i + 1} - A_{i}|. Can you help Chef? (Here |x| denotes the absolute value of x)

Under the given constraints it will always be possible to break the stick into K parts of non-zero lengths.

------ Input Format ------ 

- The first line contains a single integer T — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two space-separated integers L and K — the initial length of the stick and the number of parts Chef wants to break the stick into.

------ Output Format ------ 

For each test case, output the minimum value of \displaystyle \sum_{i = 1}^{K - 1}|A_{i + 1} - A_{i}|.

------ Constraints ------ 

$1 ≤ T ≤ 10^{4}$
$2 ≤K ≤L ≤10^{9}$

----- Sample Input 1 ------ 
2
4 3
2 2

----- Sample Output 1 ------ 
1
0

----- explanation 1 ------ 
Test Case 1: It is optimal to break the stick of length $4$ into $3$ parts in the following manner: $[2, 1, 1]$. The value of $\displaystyle \sum_{i = 1}^{K - 1}|A_{i + 1} - A_{i}| = |1 - 2| + |1 - 1| = 1$.

Test Case 2: It is optimal to break the stick of length $2$ into $2$ parts in the following manner: $[1, 1]$. The value of $\displaystyle \sum_{i = 1}^{K - 1}|A_{i + 1} - A_{i}| = |1 - 1| = 0$.