B. Bionaccia's Sequence
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In the ancient land of sequential numbers, the renowned Fibonacci family, led by the iconic Fibonacci, reigned supreme for generations. However, in a darker corner of this land, Fibonacci's cousin, Bionaccia, created her own mathematical sequence in an attempt to emulate her famous relative's success. Although Bionaccia's sequence was impressive in its own right, it was overshadowed by Fibonacci's fame.

This unfortunate eclipse prompted Bionaccia to retire and resign from the competition. But her withdrawal did not go unnoticed, and Trinacci, a darker member of the family, felt that Bionaccia had been unjustly victimized. He decided to embark on a vengeful mission. Trinacci not only plans to surpass Fibonacci but also avenge his sister Bionaccia by creating his own sequence, larger and more powerful than Fibonacci's.

The Trinacci sequence is defined as follows:

$$$t(0) = 1$$$

$$$t(1) = 2$$$

$$$t(2) = 3$$$

$$$t(n) = 3t(n - 1) + 2t(n - 2) + t(n - 3) + 3$$$ for $$$n \geq 3$$$

Trinacci and Bionaccia are interested in the value of the $$$K$$$-th term in the Trinacci sequence, i.e., $$$t(K)$$$. They want to know if Trinacci's sequence can surpass the fame of Fibonacci. However, $$$K$$$ is an extremely large number, not less than 1 nor greater than $$$10^{16}$$$.

Your task is to write a program that, given the position $$$K$$$, calculates the value of $$$t(K)$$$ in the Trinacci sequence, and the result should be taken modulo $$$10^9 + 7$$$.

Input

An integer $$$K$$$ ($$$1 \leq K \leq 10^{16}$$$).

Output

An integer: the value of $$$t(K)$$$ in the Trinacci sequence taken modulo $$$10^9 + 7$$$.

Examples
Input
6
Output
822
Input
7
Output
2983
Input
10
Output
142401