CodeTON Round 9 (Div. 1 + Div. 2, Rated, Prizes!)
G
Shohag Loves Pebae
Codeforces
3500
原题
← F2H1 →
翻译中…

Shohag has a tree with $n$ nodes.

翻译中…

Pebae has an integer $m$. She wants to assign each node a value — an integer from $1$ to $m$. So she asks Shohag to count the number, modulo $998\,244\,353$, of assignments such that following conditions are satisfied:

翻译中…
翻译中…

But this problem is too hard for Shohag to solve. As Shohag loves Pebae, he has to solve the problem. Please save Shohag!

翻译中…

Input

翻译中…

The first line contains two space-separated integers $n$ and $m$ ($2 \le n \le 10^6$, $1 \le m \le 10^{9}$).

翻译中…

Each of the next $n - 1$ lines contains two integers $u$ and $v$ ($1 \le u, v \le n$) indicating there is an edge between vertices $u$ and $v$. It is guaranteed that the given edges form a tree.

翻译中…

Output

翻译中…

Print a single integer — the number of valid ways to assign each vertex a value, modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first test case, the valid assignments are $[1, 1, 1, 1, 1, 1]$ and $[1, 1, 1, 1, 1, 5]$.

翻译中…

In the second test case, the valid assignments are $[1, 1]$, $[1, 3]$, $[1, 5]$, $[3, 1]$, $[3, 5]$, $[5, 1]$ and $[5, 3]$.

翻译中…

样例

Input #1
6 6
1 2
2 3
3 4
4 5
3 6
Output #1
2
InputCopy OutputCopy
Input #2
2 5
1 2
Output #2
7
InputCopy OutputCopy
Input #3
12 69
3 5
1 4
2 3
4 5
5 6
8 9
7 3
4 8
9 10
1 11
12 1
Output #3
444144548
InputCopy OutputCopy
题目信息
题号
2039G
时间限制
5 s
内存限制
768 MB
标签
数学
数论

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