#P8333. [ZJOI2022] 计算几何
[ZJOI2022] 计算几何
Problem Description
Jiutiao Kelian is a girl who likes computational geometry. She drew a special plane coordinate system, where the angle between the positive -axis and the positive -axis is degrees.
From it, she takes all integer points whose - and -coordinates are not both even, and that satisfy , , and .
Kelian wants to color some of these points, but adjacent points cannot be colored at the same time. Specifically, for a point , it is adjacent to the six points , , , , , and . You may understand this together with the sample explanation.
Kelian wants to know the maximum number of points that can be colored under this rule, and the number of coloring schemes that achieve this maximum. Since the latter may be very large, for the number of schemes you only need to output it modulo . Note that you do not need to take the maximum number of colored points modulo anything.
Input Format
The first line contains an integer , representing the number of test cases.
The next lines each contain three integers , , and , representing one test case.
Output Format
Output lines in total. Each line contains two integers: the maximum number of points that can be colored (not taken modulo) and the number of schemes modulo .
6
2 1 2
1 1 137
3 94 95
3 1998 1996
998244 353999 999999
50 120 150
7 4
4 1
1124 31585548
23951 33873190
1289433675488 748596399
23600 480090154
Hint
[Sample Explanation]
As shown in the figure below, point has coordinates , point has coordinates , and point has coordinates . Among these three points, only point has both coordinates even. In the figure, the points at distance from point are the six points .
In the first sample test case, the integer points satisfying the conditions are .
The maximum number of points that can be colored is , and there are schemes, namely: , , , and .
In the second sample test case, the integer points satisfying the conditions are .
The maximum number of points that can be colored is , and there is scheme, namely: .

[Constraints]
For all test points: , .
The specific limits for each test point are shown in the table below:
| Test Point ID | Special Constraints | ||
|---|---|---|---|
| None | |||
| None | |||
| None | |||
| None | |||
Translated by ChatGPT 5