Here you are given a 1-rooted tree with n vertices, with a glass ball staying on every vertex, respectively.
For every vertex u with parent v, u's altitude (namely height) is higher than v by 1 unit. Thus a ball on u can roll along edge (u, v) to v. A ball rolling along an edge takes 1 second.
All balls start rolling at the same time. There are some special vertices called ``storage vertices''. Not every vertex is storable. Besides the root, which must be storable, the probability of a vertex being storable is p. If a ball rolls to a storage vertex, it breaks, and it will be taken up from the tree. If a ball is initially on a storage vertex, it breaks immediately.
Two balls rolling to the
same vertex at the
same time is called a
collision, without considering the type of the vertex. If collision occurs, it will be a terrible incident. Not only the two balls will break, but also the whole system, and all the rolling cannot continue any more.
If collisions occur, you lose and your score is 0. Otherwise your score is
)
, where f(u) denotes the number of edges that the ball initially on u come across during the whole rolling process. Now please calculate the expect score module

.