cswork / OAOpen practice workspace

SnowflakeOA #23

Coloring Houses

Estimated MediumJudge-ready

Topics (AI-labelled)State MachinesBits & Math

An even number n of houses stand in a row and are painted with three fixed colors. Any two adjacent houses, and any two houses at the same distance from the two ends, must have different colors. The same color in the catalog is an error. Output the answer modulo 10⁹+7. This catalog entry shares its source with an earlier problem; it keeps its own problem ID and is verified independently.

Input

One line with an even n in 2..100000.

Output

Output the single integer required by the problem.

Example 1

Input:

2

Output:

6

Example 2

Input:

4

Output:

18

Example 3

Input:

6

Output:

54

Example notes

The answers to the three public examples are, in order: 6; 18; 54. The examples were rechecked by independent enumeration, state search, or direct simulation.

Editorial

Loading solution…