| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 6 | 6 | 6 | 100.000% |
Solve the problem below for $T$ test cases.
You are given two integers $M$ and $D$. You are interested in a rooted weighted tree with the following conditions.
Find the maximum number of vertices of such a tree. As the number of vertices can be very large, find the vertex count modulo $998244353$.
The first line contains an integer $T$ ($1 \leq T \leq 100$), the number of test cases. Each of the next $T$ lines contains two integers $M$ and $D$ ($1 \leq M, D \leq 10^9$) representing a case you have to solve.
For each of the $T$ test cases, output a single line containing the maximum number of vertices modulo $998244353$.
3 2 4 165 1 20 20
12 2 891869870
Explanation of Sample 1: The following illustrates, for the first case, a rooted tree with the maximum number of vertices.