Under construction

Still being built. Things may change

Expected Value

Time limit1.5sMemory limit512 MB

Summary
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.
Level

Hard8 of 10

Topics
Graph, Math, Matrix
Solved
No attempts yet

Problem

You are given a connected plane graph on nn 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 nn.

Input

The first line contains one integer nn, the number of vertices (2≤n≤30002 \le n \le 3000). The next nn lines each contain the coordinates xix_i and yiy_i of a vertex (0≤xi,yi≤50000 \le x_i, y_i \le 5000). All points are distinct.

The next line contains one integer mm, the number of edges (n−1≤m≤n(n−1)/2n - 1 \le m \le n(n-1)/2). The next mm lines each contain two integers aia_i and bib_i (1≤ai,bi≤n1 \le a_i, b_i \le n, ai≠bia_i \ne b_i), meaning there is an edge between vertices aia_i and bib_i, 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 P/QP/Q with P,Q>0P, Q > 0. Print P×Q−1P \times Q^{-1} modulo 998244353.

Examples2

  1. Example 1

    Input
    2
    0 0
    35 35
    1
    1 2
    
    Expected output
    1
    
  2. Example 2

    Input
    6
    0 0
    1 1
    2 4
    3 9
    4 16
    5 25
    8
    1 2
    2 3
    2 4
    3 4
    4 5
    5 6
    1 6
    2 6
    
    Expected output
    798595486