This page is still under construction.

Parts of this page are still being built. What you see may change.

Walk on the Main Campus 2

Time limit1sMemory limit512 MB

Summary
Count closed walks of exactly D minutes from building 1 back to building 1 in a given 8-vertex graph, modulo 1e9+7.
Level

Hard8 of 10

Topics
Graph, Matrix, Dynamic programming, Combinatorics
Solved
No attempts yet

Problem

The Information Science Building of Soongsil University sits across the road from the rest of the campus. Computer science students therefore call the main campus side "bondae" and the Information Science Building side "jeongbodae". Junyoung is a computer science student, so he spends all day inside the Information Science Building and envies the main campus, where the flowers are in full bloom. One day he decides to take a walk there. The campus map is below.

For this problem, assume the campus holds only the 8 buildings on the map and the roads between them. Number the buildings from 1 to 8.

NumberBuilding
1Information Science Building
2Computing Building
3Mirae Hall
4Sinyang Hall
5Jinri Hall
6Han Kyung-chik Memorial Hall
7Student Union
8Hyungnam Engineering Building

The following 12 pairs of buildings are joined by a road.

(1,2)(1, 2), (1,3)(1, 3), (2,3)(2, 3), (2,4)(2, 4), (3,4)(3, 4), (3,6)(3, 6), (4,5)(4, 5), (4,6)(4, 6), (5,6)(5, 6), (5,7)(5, 7), (6,8)(6, 8), (7,8)(7, 8)

Moving between two directly joined buildings takes 1 minute. Junyoung never stops on a road or inside a building during the walk. He may pass through a building or a road he already used any number of times.

Junyoung has a lot of work to do, so he walks for exactly DD minutes. He starts at building 1, the Information Science Building, and must arrive back at building 1 the moment DD minutes have passed. Two routes count as different when the sequence of buildings differs in at least one position. Count the possible routes.

Input

The first line holds an integer DD. (1≤D≤1091 \le D \le 10^9)

Output

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

Examples3

  1. Example 1

    Input
    100000000
    
    Expected output
    261245548
    
  2. Example 2

    Input
    1
    
    Expected output
    0
    
  3. Example 3

    Input
    2
    
    Expected output
    2