You are given an undirected, connected graph with vertices and edges.
A tiling of the graph is a way to cover every vertex with tiles of two types:
Each vertex must be covered by exactly one tile. Count the number of distinct tilings modulo .
The vertices form a star: vertex (center) is connected to vertices , , and (leaves).
If the center is a singleton: all three leaves must also be singletons. This gives tiling: .
If the center is paired with a leaf: there are choices of which leaf to pair with via a -node tile. The remaining two leaves are singletons. This gives tilings: ; ; .
Total: .
The graph is a -cycle: vertices ––––. List all matchings:
Total: .