#AGC057F. [AGC057F] Reflection

[AGC057F] Reflection

Score : 18001800 points

Problem Statement

There are three indistinguishable stones at integer coordinates on a number line. Consider the following operation on these stones:

  • Let A,B,CA, B, C be the three stones in ascending order of coordinate (ties broken arbitrarily). Perform one of the following.- Move AA to the symmetric position with respect to BB.
    • Move CC to the symmetric position with respect to BB.
  • Move AA to the symmetric position with respect to BB.
  • Move CC to the symmetric position with respect to BB.

You are given the initial coordinates a,b,ca, b, c of the three stones. Find the number, modulo 998244353998244353, of possible combinations of coordinates of the three stones after zero or more operations.

Note that the stones are indistinguishable. More strictly speaking, count the possible multisets of coordinates of the three stones.

We will give you TT test cases; solve each of them.

Constraints

  • 1T1051\leq T\leq 10^5
  • 1018abc1018-10^{18}\leq a\leq b\leq c\leq 10^{18}

Input

Input is given from Standard Input in the following format:

TT

case1\text{case}_1

\vdots

caseT\text{case}_T

Each case is in the following format:

aa bb cc

Output

Print TT lines. The ii-th line should contain the answer for casei\text{case}_i.

6
1 3 5
-2 -2 5
0 1 3
31 41 59
-123456789 0 987654321
-1000000000000000000 0 1000000000000000000
5
2
9
70
182333351
5

For (a,b,c)=(1,3,5)(a,b,c) = (1,3,5), the five possible combinations of the three stones after operations are:

  • (1,3,5)(1,3,5), (1,1,3)(1,1,3), (1,1,1)(-1,1,1), (3,5,5)(3,5,5), (5,5,7)(5,5,7).

The figure below may be helpful.