#P10588. 「ALFR Round 2」D 超立方体
「ALFR Round 2」D 超立方体
Background
What comes into view is a huge cherry blossom tree.
Under the tree stands a girl, looking up at it.
I think: She is probably a freshman. Maybe, like me, she also sneaked out.
I also look up at that cherry blossom tree. The blurry colors of the blossoms cover the sky.
A gust of wind rises, and the dancing cherry blossom petals wrap around the girl.
The girl also sees me...
Problem Description
That was your first encounter with Milja.
As always, Milja gives you another sequence problem.
The white envelope carries a scent of citrus,
and you carefully open it and read.
In 3D, we have a cube.
The coordinates of its vertices can all be written in the form .
Similarly, in dimensions, we have an -dimensional hypercube with vertices.
Its edge length is , and every coordinate of every vertex is a non-negative integer.
Starting from the point , you walk along edges. Find the total number of ways to arrive at the point .
Among the coordinates of the destination point, there are digits equal to .
Since the answer may be very large, you only need to output the result modulo .
Input Format
The first line contains an integer , which denotes the number of test cases.
The next lines each contain three non-negative integers .
Output Format
For each test case, output one line containing one integer: the answer.
5
3 3 1
3 4 0
114 514 86
19198 10101 7211
604800 4089470473293004800 443520
7
21
191637399
939162608
305624040
Hint
Sample Explanation
The ways in the first example are:
Constraints
| Subtask | Points | Constraints |
|---|---|---|
| , | ||
| - |
For of the testdata: , , , , .
You turn to the back and find a line of small text:
Please do not forget to consider special cases.
Translated by ChatGPT 5