1397. Chino's homework

Chimame March is about to go to high school and will take a graduation photo. So they plan totrim their hair and groom themselves.

Megu asked Chiya and Syaro for help, Maya asked Rize for help, and Chino asked Cocoa for help.

While Cocoa was trimming Chino’s hair, the two were discussing Chino’s desire to go to school. Cocoa hopes Chino can go to her high school, and Chino intends to do so. But Chino joked: ”Sure enough, it’s better to go to a different school.” As a result, Cocoa was surprised and suddenly shookher hand. Chino’s hair was cut like this:

Chino was angry. She took Cocoa’s hand and asked her to cooperate with herself to complete ahomework assigned by the teacher:

Chino’s teacher gave her a chessboard of n×m. Her teacher asked both players to use u and v pieces respectively (it could be assumed that Chino would use u chess pieces and Cocoa would use v chess pieces, both of them didn’t have to use all of these chess pieces.), and arbitrarily placed them in this chessboard grid. And they could only put at most one chess piece in each grid.Then calculated the maximum points according to the following rules, and Chino wrote the result in the workbook and returned it to the teacher.

  • Chino was an introvert. Every time she placed a pawn, then 12 points are added. But for allher chess pieces, every time there was a neighbor (whether it was her own or the opponent’s), 3 points are subtracted.
  • Cocoa was an extrovert. Every time she places a piece, then 4 points are added. And for allher chess pieces, every time there was a neighbor (whether it was her own or the opponent’s),another 2 points are added.
  • Neighbors refer to the chess pieces in the 4 grids up, down, left and right of this certain grid.

Cocoa is good at calculations. She thought this question was too simple. She planed to continueto test Chino’s mathematics ability (so that her math scores could be better and she could go toCocoa’s own school). She asked Chino: ”How many ways are there to achieve the maximum points?”(Assuming that under the two ways, the sets of coordinates for Chino’s placement of chess pieces are S_1,S^′_1, and Cocoa’s are S_2,S^′_2. The two ways are different if and only if S_1 is different from S^′_1 or S_2 is different from S^′_2). Chino felt that the previous question was difficult enough, but Cocoa came up with a more dif-ficult one. She hopes to ask you to solve these two problems. Can you help her?

输入

The three integers n, m and Q \ (1≤n, m≤5, Q≤49) in the first line are separated by spaces. Q means there are Q queries. Next Q line, each line two integers u and v \ (0≤u, v≤6).

输出

For each query, output two integers on a line, separated by spaces. The two numbers represent the answer to the teacher’s question and the answer to the Cocoa’s question.

样例

标准输入 复制文本
1 2 3
1 1
2 0
0 0
标准输出 复制文本
15 2
18 1
0 1
标准输入 复制文本
2 3 1
1 2
标准输出 复制文本
24 8

提示

For the first query of the first sample, here are the following two ways:

| Chino | Cocoa |

| Cocoa | Chino |

For the third query, putting nothing is also a way.

For the second sample, two of eight methods are as follows:

| Chino | | | | | Cocoa | Cocoa |

| Chino | | Cocoa | | | | Cocoa |

来源

SCNUCPC 2020 现场赛

登录以提交代码。
单点时限 1 秒
内存限制 256 MB
提交 25
通过 7