#P9373. 「DROI」Round 2 构造与取模

「DROI」Round 2 构造与取模

Background

Instead of writing a weak background, it is better to create a higher-quality problem.

Problem Description

For integers n,kn, k, if there exist a non-negative integer xx and a positive integer yy such that:

x+y=n  xmody=kx + y = n\ \land\ x \bmod y =k

then we call the ordered pair (x,y)(x, y) an excellent split of nn (where \land means and).

Now given non-negative integers n,kn, k, please construct any excellent split of nn, and output the xx and yy in your construction. In particular, if no such split exists, output -1.

Input Format

This problem has multiple test cases.

The first line contains a positive integer TT, representing the number of test cases.

The next TT lines each contain two non-negative integers, n,kn, k.

Output Format

Output a total of TT lines. The ii-th line gives the answer for the ii-th test case.

3
1 0
13 3
198818800000 122122200000
0 1
8 5
-1

Hint

Sample Explanation

For the first test case, there is only one possible construction.

For the second test case, (3,10)(3,10) is also a valid construction.

For the third test case, it can be proved that no valid construction exists.


Constraints

"This problem uses bundled tests."

  • Subtask1(20%)\operatorname{Subtask} 1(20\%): n106n \leq 10^6.

  • Subtask2(40%)\operatorname{Subtask} 2(40\%): n1012n \leq 10^{12}.

  • Subtask3(40%)\operatorname{Subtask} 3(40\%): no special restrictions.

For 100%100\% of the testdata: T5T \leq 5, 0n,k10180 \leq n, k \leq 10^{18}.

Translated by ChatGPT 5