Order Capital Round 1 (Codeforces Round 1038, Div. 1 + Div. 2)
G
Tree Parking
Codeforces
3300
原题
← F→
翻译中…

Consider the following problem statement:

翻译中…
  • You are given a tree with $n$ vertices rooted at $1$. For each $1 \leq i \leq n$, a car will enter the root at time $l_i$. It will then instantaneously travel from the root to vertex $i$ through the unique simple path and park there. It will leave through the same path in the other direction at time $r_i$.During the time when a car is parked in a vertex, it blocks other cars from traveling through that vertex. The tree is called valid if and only if all cars are able to enter and leave the tree at their desired times.Count the number of pairs of sequences $l$, $r$ such that $l_i \lt r_i$, their concatenation is a permutation of $1 \ldots 2n$, and the tree is valid.
翻译中…

Calculate the sum of the answers to the problem over all labeled trees$^{\text{∗}}$ with $n$ vertices and $k$ leaves. The root is not considered a leaf. Since the answer may be large, calculate it modulo $998\,244\,353$.

翻译中…

$^{\text{∗}}$Two labeled trees are considered different if and only if their edge sets are different.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The only line of each test case contains two integers $n$, $k$ ($1 \leq k \lt n \leq 2 \cdot 10^5$) — the number of vertices and leaves of the tree, respectively.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output one integer — the answer modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first case, there is only one tree that satisfies the constraints. The correct pairs of sequences are: $$ (l, r) = \bigl([1, 3], [2, 4]\bigr),\:\bigl([3, 1], [4, 2]\bigr),\:\bigl([2, 1], [3, 4]\bigr). $$

翻译中…

样例

Input #1
3
2 1
8 3
65 43
Output #1
3
899171636
38330886
InputCopy OutputCopy
题目信息
题号
2122G
时间限制
2 s
内存限制
256 MB
标签
组合数学
FFT
数学
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。