Simple Graph
Time limit1sMemory limit512 MB
Sum x^k over all simple graphs on n labeled vertices, where x counts the tree components, modulo 998244353.
- Level
Hard9 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Graph
- Solved
- No attempts yet
Problem
An undirected simple graph can be divided into connected components. Let be the number of trees among these components. Then the value of graph is defined as .
Given and , calculate the sum of values of all undirected simple graphs with exactly labeled vertices. Print the answer modulo .
A simple graph is an undirected graph in which both multiple edges and loops are disallowed. A connected component (or just component) of an undirected graph is a subgraph in which any two vertices are connected to each other by paths, and which is not connected to any other vertex in the graph.
Input
The first line contains an integer , denoting the number of test cases. Each of the next lines contains two space-separated integers and (, ).
Output
For each test case, print a single line containing the answer.