Expected Value
Time limit1.5sMemory limit512 MB
Given a connected plane straight-line graph, find the expected first hitting time of vertex n from vertex 1 in a random walk, modulo 998244353.
Problem
You are given a connected plane graph on vertices. At first, you stand at vertex 1. Each second you move to an adjacent vertex, chosen uniformly at random among all vertices adjacent to your current one. Compute the expected value of the first time you arrive at vertex .
Input
The first line contains one integer , the number of vertices (). The next lines each contain the coordinates and of a vertex (). All points are distinct.
The next line contains one integer , the number of edges (). The next lines each contain two integers and (, ), meaning there is an edge between vertices and , drawn as the straight segment between their points. No two segments intersect except at shared endpoints, there are no multiple edges, and the graph is connected.
Output
It is guaranteed that in the given tests the expected value can be written as an irreducible fraction with . Print modulo 998244353.