Permutation on Tree
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Given a tree with n vertices where vertex r is the root, we say a permutation of n is good if it satisfies the following constraint:
Let a_x be the index of x in the permutation (That is, ). For all , if vertex u is an ancestor of vertex v in the tree, then .
Define the score of a permutation to be where is the absolute value of x. Calculate the sum of scores of all different good permutations.

输入描述:

There is only one test case in each test file.
The first line contains two integers n and r (, ) indicating the size of the tree and the root.
For the following (n - 1) lines, the i-th line contains two integers u_i and v_i () indicating an edge connecting vertex u_i and v_i in the tree.

输出描述:

For each test case output one line containing one integer indicating the sum of scores of all different good permutations. As the answer may be large, output the answer modulo .
示例1

输入

复制
4 2
1 2
2 3
1 4

输出

复制
15
示例2

输入

复制
3 1
1 2
2 3

输出

复制
2

备注:

For the first sample test case, there are three good permutations: , and . Their scores are 4, 5 and 6 respectively so the answer is .
For the second sample test case, there is only one good permutation: . It's score is 2.