QOJ.ac

QOJ

Time Limit: 3.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#14426. Grid Problem

Statistics

Yotsugi was playing with a grid $A$ of height $h$ and width $w$, which was initially filled with zeroes by applying the following 2 operations in some order:

  • Pick values $i, j$ ($0 \le i \le h - 1, 0 \le j \le w - 1$) and sign $+$ or $-$, and change values $A_{i,j}, A_{i,j+1}, A_{i+1,j}, A_{i+1,j+1}$ to $A_{i,j} \pm 2, A_{i,j+1} \pm 1, A_{i+1,j} \pm 1, A_{i+1,j+1} \pm 2$ correspondingly, where $\pm$ is replaced with the chosen sign. Here Yotsugi considers $A_{h,j}$ to be equivalent to $A_{0,j}$ and $A_{i,w}$ to be equivalent to $A_{i,0}$. In other words, she treats her grid as a torus.
  • Pick values $i, j$ ($0 \le i \le h - 1, 0 \le j \le w - 1$) and sign $+$ or $-$, and change values $A_{i,j}, A_{i,j+1}, A_{i,j+2}, A_{i+1,j}, A_{i+1,j+1}, A_{i+1,j+2}, A_{i+2,j}, A_{i+2,j+1}, A_{i+2,j+2}$ to $A_{i,j} \pm 2, A_{i,j+1} \pm 5, A_{i,j+2} \pm 2, A_{i+1,j} \pm 5, A_{i+1,j+1} \pm 5, A_{i+1,j+2} \pm 5, A_{i+2,j} \pm 2, A_{i+2,j+1} \pm 5, A_{i+2,j+2} \pm 2$ correspondingly, where $\pm$ is replaced with the chosen sign. As in the previous operation, Yotsugi treats the grid as a torus.

For easier understanding of the operations, refer to the notes section.

On the next day, the grid was eaten by the fire-breathing slug, and now Yotsugi wonders how many possible grids she could have if, after she finished applying operations, all values $A_{i,j}$ lay in $[0, k]$. Notice that when Yotsugi was applying operations, values $A_{i,j}$ could be negative or exceed $k$. Since the answer can be large, help her find it modulo $10^9 + 9$.

Input

First line contains 3 integers $h, w, k$ ($3 \le h, w \le 1\,000$, $1 \le k \le 10^9$) — size of the grid and maximum possible value in the grid.

Output

Output the answer to the problem modulo $10^9 + 9$.

Examples

Input 1

3 3 1

Output 1

2

Input 2

4 4 52

Output 2

972950693

Input 3

7 10 123

Output 3

93519598

Note

For example, if we had a $4 \times 4$ matrix, we could apply the operations in the following manner:

problem_14426_bdc5aaccf4f57ccf8e281b69a642fa5f.png

Applying the first operation with sign $-$.

problem_14426_c7868b974cacb61057c7998f75650c36.png

Applying the second operation with sign $+$.

problem_14426_bc6d6c6bdfd571cbf1363a33e2c0b200.png

Applying the first operation with sign $+$.

problem_14426_0aa751704d08e9f39b2346eade004eb7.png

Applying the first operation with sign $+$.

And since all values lie in $[0, 42]$, this is one of the matrices you are asked to count in the second sample.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#364EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.