Horizontal puzzle

Have an infinite collection of pieces 1×11 \times 1, 1×21 \times 2 and 2×22 \times 2, and you must completely fill a 2×n2 \times n rectangle. In how many ways can you do it?

For example, this is one of the many ways for n=7n = 7:

(9,4)

(1,1)(1,0)7 (1,1)(0,1)2 (8,3)(-1,0)7 (8,3)(0,-1)2

(2,1)(0,1)2 (2,2)(1,0)1 (3,1)(0,1)1 (3,2)(1,0)1 (4,2)(0,1)1 (4,2)(1,0)1 (5,1)(0,1)2 (7,1)(0,1)2 (7,2)(1,0)1

Input

Input consists of several cases, each with an nn between 1 and 10410^4.

Output

For every case, print the number of ways to fill a 2×n2 \times n rectangle. Since this number can be very large, make the computations modulo 108+710^8 + 7.

Observation

It may be helpful to compute a quantity similar to the one asked for in the problem.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:46:48.344Z

© Jutge.org, 2006–2026.
https://jutge.org