#P5450. [THUPC 2018] 淘米神的树

[THUPC 2018] 淘米神的树

Problem Description

Lovely Tommy has a tree. In this tree, only vertices aa and bb are black, and all other vertices are white.

Each time, Tommy can recolor a black vertex pp to red, and then recolor all white vertices adjacent to pp into black. In the end, all vertices will be recolored to red.

Let the ii-th vertex be recolored to red as the tit_i-th one; then tit_i is a permutation of 11 to nn. Tommy wants you to help him find how many different tit_i there are.

Input Format

Each input file contains only one testdata.

  • The first line contains three positive integers n,a,bn,a,b separated by spaces, representing the number of vertices of the tree and the indices of the initial black vertices.

  • The next n−1n-1 lines each contain two positive integers x,yx,y, describing an edge (x,y)\left( x,y\right) in the tree.

The vertices of the tree are numbered starting from 11.

Output Format

Output 11 line:

  • One integer, representing the number of different permutations tit_i modulo 998,244,353998,244,353.
4 1 2
1 2
2 3
3 4
4

Hint

Constraints

It is guaranteed that a,b≤n≤234,567a,b\le n\le 234,567.

From the 2018 Tsinghua University Programming Contest and Collegiate Invitational (THUPC2018). Thanks to Pony.ai for supporting this contest.

Resources such as editorials can be found at https://github.com/wangyurzee7/THUPC2018.

Translated by ChatGPT 5