Walk on the Main Campus 2
Time limit1sMemory limit512 MB
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.
The following 12 pairs of buildings are joined by a road.
, , , , , , , , , , ,
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 minutes. He starts at building 1, the Information Science Building, and must arrive back at building 1 the moment 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 . ()
Output
Print the number of possible routes modulo on the first line.