#arc158d. [arc158_d]Equation

[arc158_d]Equation

Problem Statement

You are given a positive integer nn, and a prime number pp at least 55.

Find a triple of integers (x,y,z)(x,y,z) that satisfies all of the following conditions.

  • 1leqx<y<zleqp11\\leq x < y < z \\leq p - 1.
  • $(x+y+z)(x^n+y^n+z^n)(x^{2n}+y^{2n}+z^{2n}) \\equiv x^{3n}+y^{3n}+z^{3n}\\pmod{p}$.

It can be proved that such a triple (x,y,z)(x,y,z) always exists.

You have TT test cases to solve.

Constraints

  • 1leqTleq1051\\leq T\\leq 10^5
  • 1leqnleq1091\\leq n\\leq 10^9
  • pp is a prime number satisfying 5leqpleq1095\\leq p\\leq 10^9.

Input

The input is given from Standard Input in the following format:

TT textcase1\\text{case}_1 vdots\\vdots textcaseT\\text{case}_T

Each case is in the following format:

nn pp

Output

Print TT lines. The ii-th line should contain x,y,zx,y,z with spaces in between where (x,y,z)(x,y,z) is a solution for the ii-th test case.

If multiple solutions exist, you may print any of them.


Sample Input 1

3
1 7
2 7
10 998244353

Sample Output 1

1 4 6
1 2 5
20380119 21549656 279594297

For the first test case:

  • $(x+y+z)(x^n+y^n+z^n)(x^{2n}+y^{2n}+z^{2n}) = (1+4+6)(1+4+6)(1+16+36) = 6413$, and
  • x3n+y3n+z3n=1+64+216=281x^{3n}+y^{3n}+z^{3n} = 1 + 64 + 216 = 281.

We have 6413equiv281pmod76413\\equiv 281\\pmod{7}, so the conditions are satisfied.