Limits 2s, 512 MB

You will be given NN and MM, how many ways we can take two numbers from 1 to NN so that their absolute difference is divisible by MM. As the answer can be quite big, give the modulo of the answer by 10000000091000000009 (1e9+91e9+9).

Input

First line of the input is TT (T100000T ≤ 100000), then TT test cases follows. Each case have only one line containing two positive integers NN and MM (1N,M10181 ≤ N, M ≤ 10^{18}).

Output

For each test case, output a line containing "Case I: d" where II is test case number and dd is the answer modulo by 10000000091000000009.

Sample

InputOutput
2
4 3
7 5
Case 1: 1
Case 2: 2

In the first case, There we can only take 1 and 4 between 1 to 4 whose difference 3 is divisible by 3. For second case the pairs are (1,6)(1, 6) and (2,7)(2, 7).


Submit

Login to submit.

Statistics

50% Solution Ratio
Double_OEarliest, Apr '18
sayeef006Fastest, 0.0s
Double_OLightest, 2.2 MB
raiyan.sidneShortest, 301B
Toph uses cookies. By continuing you agree to our Cookie Policy.