#P5456. [THUPC 2018] 蛋糕
[THUPC 2018] 蛋糕
Description
Recently, Feifei learned how to make cakes. She made a 4D cake for Niuniu. The size of the cake is: .
All surfaces of the cake are covered with cream. Niuniu wants to cut the cake into small pieces along hyperplanes parallel to the surfaces.
Now, Niuniu wants to know, among these small pieces, how many pieces have surface, surface, surfaces, , surfaces covered with cream, respectively.
Input Format
The input contains multiple test cases. The first line contains an integer indicating the number of test cases. ()
Each test case is described as follows:
- One line with positive integers , , , . (All four positive integers are within )
Output Format
For each test case, output one line:
- Output integers, representing the number of small pieces that have surface, surface, surfaces, , surfaces covered with cream, respectively. Separate the values with a single space. To prevent the answer from being too large, you only need to output each value modulo .
5
2 2 2 3
7 7 8 8
9 9 9 9
3 3 5 6
9 7 5 2
0 0 0 8 16 0 0 0 0
900 1320 724 176 16 0 0 0 0
2401 2744 1176 224 16 0 0 0 0
12 62 108 72 16 0 0 0 0
0 210 284 120 16 0 0 0 0
Hint
Sample Explanation
For the first test case, after cutting a cake into small pieces, a total of small cubes are formed. Among them, pieces are each adjacent to the other pieces, so they have faces covered with cream. The other pieces are each adjacent to the other pieces, so they have faces covered with cream.
Copyright Information
From the 2018 Tsinghua University Programming Contest and Intercollegiate Invitational (THUPC2018). Thanks to Pony.ai for supporting this contest.
Resources such as solutions can be found at https://github.com/wangyurzee7/THUPC2018.
Translated by ChatGPT 5
京公网安备 11011102002149号