#P1254D. Tree Queries
Tree Queries
Description
Hanh is a famous biologist. He loves growing trees and doing experiments on his own garden.
One day, he got a tree consisting of vertices. Vertices are numbered from to . A tree with vertices is an undirected connected graph with edges. Initially, Hanh sets the value of every vertex to .
Now, Hanh performs operations, each is either of the following types:
- Type : Hanh selects a vertex and an integer . Then he chooses some vertex uniformly at random, lists all vertices such that the path from to passes through . Hanh then increases the value of all such vertices by .
- Type : Hanh selects a vertex and calculates the expected value of .
Since Hanh is good at biology but not math, he needs your help on these operations.
The first line contains two integers and () — the number of vertices on Hanh's tree and the number of operations he performs.
Each of the next lines contains two integers and (), denoting that there is an edge connecting two vertices and . It is guaranteed that these edges form a tree.
Each of the last lines describes an operation in either formats:
- (), representing a first-type operation.
- (), representing a second-type operation.
It is guaranteed that there is at least one query of the second type.
For each operation of the second type, write the expected value on a single line.
Let , it can be shown that the expected value can be expressed as an irreducible fraction , where and are integers and . Output the integer equal to . In other words, output such an integer that and .
Input
The first line contains two integers and () — the number of vertices on Hanh's tree and the number of operations he performs.
Each of the next lines contains two integers and (), denoting that there is an edge connecting two vertices and . It is guaranteed that these edges form a tree.
Each of the last lines describes an operation in either formats:
- (), representing a first-type operation.
- (), representing a second-type operation.
It is guaranteed that there is at least one query of the second type.
Output
For each operation of the second type, write the expected value on a single line.
Let , it can be shown that the expected value can be expressed as an irreducible fraction , where and are integers and . Output the integer equal to . In other words, output such an integer that and .
Note
The image below shows the tree in the example:

For the first query, where and :
- If , the values of all vertices get increased.
- If , the values of vertices and get increased.
- If , the values of vertices , , and get increased.
- If , the values of vertices and get increased.
- If , the values of vertices and get increased.
Hence, the expected values of all vertices after this query are ().
For the second query, where and :
- If , the values of vertices , and get increased.
- If , the values of all vertices get increased.
- If , the values of vertices , and get increased.
- If , the values of vertices , , and get increased.
- If , the values of vertices , , and get increased.
Hence, the expected values of all vertices after this query are ().