luogu#P7850. 「JZOI-2」干大事

「JZOI-2」干大事

Background

All the members are thinking about organizing an anniversary event, but Xiao Xi only wants to slack off.

So Xiao Xi decided to do something big (go slack off in a big way).

Problem Description

Because Xiao Xi often slacks off, he is very popular among the slackers. Today, Xiao Xi decides to livestream on the most "degenerate" tree in the fish world.

This tree is very "degenerate". It has no root. It has nn nodes, labeled 1,2,,n1,2,\dots,n, and there are n1n - 1 edges connecting them. It can change its form: edges may move, disappear, or grow. Let kk be the number of edges (u,v)(u,v) in the tree that satisfy uv=1|u-v|=1. Then the value of this form is k×ckk \times c^k.

Xiao Xi wants to introduce the value of the tree to the salted fish, but he only wants to slack off. So he asks you to compute the sum of the values over all different forms of the tree, and output it modulo 998244353998244353.

Multiple test cases.

Input Format

The first line contains a positive integer TT, the number of test cases.
The next TT lines each contain a positive integer nn and a non-negative integer cc, describing one test case.

Output Format

Output TT lines. The ii-th line contains a non-negative integer, the answer for the ii-th test case.

3
4 2
4 3
5 1

94
228
200

Hint

For 10%10\% of the testdata, T=1T = 1, n10n \le 10.
For 30%30\% of the testdata, T10T \le 10, n300n \le 300.
For 70%70\% of the testdata, T10T \le 10, n106n \le 10^6.
For 100%100\% of the testdata, 1T1051 \le T \le 10^5, 1n10181 \le n \le 10^{18}, 1c<9982443531 \le c < 998244353.

Translated by ChatGPT 5