Under construction

Still being built. Things may change

Erase Nodes

Time limit7sMemory limit512 MB

Summary
Nodes of a connected graph with n nodes and n edges are removed in random order; find the expected number of BFS updates, modulo 998244353.
Level

Hard8 of 10

Topics
Probability, Graph, Tree, Divide and conquer
Solved
No attempts yet

Statement

Bob's job is to maintain a network, which can be represented as a connected graph having nn nodes and nn undirected edges. Now he has to close the entire network.

In the beginning, all nodes are active. During the closing process, he repeatedly selects one active node and inactivates it until no active node remains. Each active node has a table that stores the connectivity information from that node to every other active node. When a node uu is inactivated, every active node vv (including uu itself) that could reach uu must update its table. Each update may change several records, since one inactivation can split a connected component into several smaller components, but the cost of each update is almost the same: running a breadth-first search from vv.

A bad order makes the number of updates large. Bob does not know how to find a good order, so he selects one active node uniformly at random at each step. Find the expected number of updates.

To avoid precision issues, if the answer is an irreducible fraction p/qp/q, report the minimum non-negative integer rr such that qr≡p(mod998244353)q r \equiv p \pmod{998244353}. For example, 6×166374072≡796 \times 166374072 \equiv 79 and 3×332748131≡40(mod998244353)3 \times 332748131 \equiv 40 \pmod{998244353}.

Input

The input contains several test cases. The first line contains an integer TT, the number of test cases. Each test case begins with an integer nn. Each of the following nn lines contains two integers uu and vv, representing an edge between the uu-th node and the vv-th node.

Output

For each test case, output a line containing "Case #x: y", where xx is the test case number starting from 1, and yy is the answer to that test case.

Constraints

  • 1≤T≤1001 \le T \le 100
  • 3≤n≤1053 \le n \le 10^5
  • 1≤u<v≤n1 \le u < v \le n
  • The sum of nn over all test cases does not exceed 5×1055 \times 10^5.
  • The edges of each test case are distinct. There are no multiple edges.

Examples1

  1. Example 1

    Input
    2
    5
    1 2
    1 3
    1 4
    2 4
    2 5
    5
    1 2
    1 3
    1 4
    1 5
    2 5
    
    Expected output
    Case #1: 166374072
    Case #2: 332748131