Count closed walks of exactly D minutes from building 1 back to building 1 in a given 8-vertex graph, modulo 1e9+7.
Hard8GraphMatrixDynamic programmingCombinatoricsNo attempts yetTime limit1sMemory limit512 MBThe 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.
| Number | Building |
|---|---|
| 1 | Information Science Building |
| 2 | Computing Building |
| 3 | Mirae Hall |
| 4 | Sinyang Hall |
| 5 | Jinri Hall |
| 6 | Han Kyung-chik Memorial Hall |
| 7 | Student Union |
| 8 | Hyungnam Engineering Building |
The following 12 pairs of buildings are joined by a road.
(1,2), (1,3), (2,3), (2,4), (3,4), (3,6), (4,5), (4,6), (5,6), (5,7), (6,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 D minutes. He starts at building 1, the Information Science Building, and must arrive back at building 1 the moment D minutes have passed. Two routes count as different when the sequence of buildings differs in at least one position. Count the possible routes.
The first line holds an integer D. (1≤D≤109)
Print the number of possible routes modulo 109+7 on the first line.