#P1097G. Vladislav and a Great Legend
Vladislav and a Great Legend
Description
A great legend used to be here, but some troll hacked Codeforces and erased it. Too bad for us, but in the troll society he earned a title of an ultimate-greatest-over troll. At least for them, it's something good. And maybe a formal statement will be even better for us?
You are given a tree with vertices numbered from to . For every non-empty subset of vertices of , let be the minimum number of edges in the smallest connected subtree of which contains every vertex from .
You're also given an integer . You need to compute the sum of among all non-empty subsets of vertices, that is:
As the result might be very large, output it modulo .
The first line contains two integers and (, ) — the size of the tree and the exponent in the sum above.
Each of the following lines contains two integers and () — the indices of the vertices connected by the corresponding edge.
It is guaranteed, that the edges form a tree.
Print a single integer — the requested sum modulo .
Input
The first line contains two integers and (, ) — the size of the tree and the exponent in the sum above.
Each of the following lines contains two integers and () — the indices of the vertices connected by the corresponding edge.
It is guaranteed, that the edges form a tree.
Output
Print a single integer — the requested sum modulo .
Note
In the first two examples, the values of are as follows: