##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
You are given a tree with vertices, numbered from to .
There are two pieces of iron. Initially, one of them is on vertex , and the other one is on vertex .
In one operation, you choose a vertex and place a magnet on it for one second. During this second, each piece of iron behaves independently:
After that, the magnet is removed.
A sequence of operations is successful if after all operations both pieces of iron are on the same vertex.
Among all successful sequences with the minimum possible number of operations, count how many different sequences exist. Two sequences are considered different if for some operation position, the chosen magnet vertices are different.
Output the answer modulo .
If the two pieces of iron are already on the same vertex, the empty sequence is considered the only optimal sequence.