PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000038. Kiến bò trên tứ diện (Tetrahedron)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Kiến bò trên tứ diện (Tetrahedron)

Tetrahedron

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A tetrahedron has four vertices labeled A,B,C,DA,B,C,D. Every pair of distinct vertices is joined by an edge.

An ant starts at vertex DD. On every step, it must traverse an edge to a different vertex; remaining at the current vertex is forbidden.

Count the paths of exactly nn steps that end at vertex DD again. Two paths are different if the vertex visited at any step differs. Print the answer modulo 109+710^9+7.

Input

One line containing integer nn, the exact number of steps.

Output

Print the number of walks from DD back to DD in exactly nn steps, modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤n≤251\le n\le 25.
  • Subtask 2 (30 points): 1≤n≤1051\le n\le 10^5.
  • Subtask 3 (50 points): 1≤n≤1071\le n\le 10^7.

Examples

Input

2

Output

3

Explanation

On the first step the ant moves from DD to one of A,B,CA,B,C. The second step returns it to DD. The three paths are D→A→DD\to A\to D, D→B→DD\to B\to D, and D→C→DD\to C\to D, giving answer 33.