Tiling a 3 by N Wall

Count the tilings of a 3 by N wall with dominoes, modulo 1e9+7, where N can be as large as 10^18.

Medium7Dynamic programmingMatrixCombinatoricsNo attempts yetTime limit2sMemory limit512 MB

Problem

Count the ways to fill a 3×N3 \times N wall completely with 2×12 \times 1 tiles and 1×21 \times 2 tiles. Tiles must not overlap and must not stick out of the wall. You may use any number of tiles of either shape.

Input

The first line contains NN (1N10181 \le N \le 10^{18}).

Output

Print the number of ways modulo 109+710^9 + 7 on the first line.