cho.sh
Notes
Loading...

Tetris

Time limit

2s

Memory limit

128 MB

Problem

You want to fill a 3×N3 \times N3×N rectangle completely with Tetris pieces.

The available pieces are the six tetrominoes shaped like a square, T, S, Z, L, and J. You may use each piece as many times as needed, and each piece may be rotated by 90∘90^\circ90∘, 180∘180^\circ180∘, or 270∘270^\circ270∘. The straight 1×41 \times 41×4 tetromino is not used.

Pieces must be placed on the grid, must not overlap, and must not extend outside the rectangle. Count the number of possible tilings.

Input

The first line contains a positive integer NNN. NNN is at most 300300300.

Output

Print the number of ways to fill the 3×N3 \times N3×N rectangle with the pieces, modulo 1,000,0001{,}000{,}0001,000,000.