#P7578. 「RdOI R2」数(number)

「RdOI R2」数(number)

Description

Find three distinct positive integers x,y,z(x>y>z)x,y,z(x\gt y\gt z) such that, for any two of them, their sum is divisible by the third number.

Now you are given several types of requirements as follows:

  • Given the value of xyx-y, find x,y,zx,y,z.
  • Given the value of xzx-z, find x,y,zx,y,z.
  • Given the value of yzy-z, find x,y,zx,y,z.

Input Format

There are T+1T+1 lines in total.

The first line contains an integer TT, indicating that there are TT test cases.

The next TT lines each contain two items:

  1. A string, which can be xyx-y, xzx-z, or yzy-z, indicating which two numbers were subtracted to obtain the given value.
  2. A number, the value of this difference.

Output Format

There are TT lines in total.

Each line outputs three positive integers x,y,zx,y,z (as described above). The problem guarantees that a solution exists.

1
x-y 1
3 2 1

Hint

Sample Explanation

From xy=1x-y=1, we know that the difference between xx and yy is 11. After trying, we get x=3,y=2,z=1x=3,y=2,z=1.

It is then clear that z(x+y)z\mid (x+y), y(x+z)y\mid (x+z), and x(y+z)x\mid (y+z).


Constraints

  • For 1%1\% of the testdata, i.e., Sample #1.
  • For 100%100\% of the testdata, 1T106,1x,y,z1081\le T\le 10^6,1\le x,y,z\le10^8.

Translated by ChatGPT 5