#P2100. 凌乱的地下室

凌乱的地下室

Description

In Xiao Z’s basement, there are nn small blocks placed side by side (Xiao Z is a hardcore MC fan who likes decorating his basement with small blocks), and each block is different (Xiao Z likes things to be unique), such as grass block, marble, obsidian, etc.

Xiao Z likes to arrange these small blocks in a special order, for example: grass block, marble, obsidian. One day, Xiao D helped Xiao Z tidy up the basement, but the not-so-bright Xiao D forgot the exact positions after moving all the blocks out. With only a vague memory, Xiao D might place the block originally at position ii to any of positions i1i-1, ii, or i+1i+1 (of course, the 11st cannot be placed at position 00, and the nnth cannot be placed at position n+1n+1), for example (corresponding to the example above): marble, grass block, obsidian.

Xiao Z is a generous person. He wants to compute how many possible final arrangements Xiao D could make, and he will not hold Xiao D responsible. Since he is also not very bright, if the answer is large, he only wants to see the last 88 digits (do not show leading zeros).


Count the number of permutations {pn}\{p_n\} of 1n1 \sim n that satisfy pii1|p_i-i| \le 1, and take the answer modulo 10810^8.

Input Format

One line, a positive integer nn, meaning there are nn small blocks in Xiao Z’s basement.

Output Format

One line, a positive integer, the number of possible final arrangements Xiao D could make. Output only the last 88 digits, and do not output leading zeros.

3
3
987
223731

Hint

[Sample Explanation 1]

Continuing the example in the statement, there are 33 possibilities: (grass block, marble, obsidian), (marble, grass block, obsidian), (grass block, obsidian, marble).

[Constraints]

For 30%30\% of the testdata, n106n \le 10^6.

For 50%50\% of the testdata, n1016n \le 10^{16}.

For 100%100\% of the testdata, 1n1010001 \le n \le 10^{1000}.

Translated by ChatGPT 5