Snow has arrived on the farm, and as she does at the beginning of every winter, Bessie is building a snow-cow! Most of the time, Bessie strives to make her sculpture look as much like a real cow as possible. However, feeling artistically inspired, this year she decides to pursue a more abstract route and build a sculpture in the shape of a tree, consisting of N snowballs connected by N−1 branches, each connecting a pair of snowballs such that there is a unique path between every pair of snowballs.
Bessie has added a nose to one of the snowballs, so it represents the head of the abstract snow cow. She designates it as snowball number 1. To add more visual interest, she plans to dye some of the snowballs different colors in an artistic fashion by filling old milk pails with colored dye and splashing them onto the sculpture. Colors are identified by integers in the range 1…100000, and Bessie has an unlimited supply of buckets filled with dyes of every possible color.
When Bessie splashes a snowball with a bucket of dye, all the snowballs in its subtree are also splashed with the same dye (snowball y is in the subtree of snowball x if x lies on the path from y to the head snowball). By splashing each color with great care, Bessie makes sure that all colors a snowball has been splashed with will remain visible. For example, if a snowball had colors [1, 2, 3] and Bessie splashes it with color 4, the snowball will then have colors [1, 2, 3, 4].
After splashing the snowballs some number of times, Bessie may also want to know how colorful a part of her snow-cow is. The "colorfulness" of a snowball x is equal to the number of distinct colors c such that snowball x is colored c. If Bessie asks you about snowball x, you should reply with the sum of the colorfulness values of all snowballs in the subtree of x.
Please help Bessie find the colorfulness of her snow-cow at certain points in time.
The first line of input contains 2 integer N and Q (the number of queries).
The next N-1 lines of input contains 2 integers a and b, representing an edge from node a to node b. It is guaranteed that a tree will be formed from the egdes.
The next Q lines will contain a query each. A query of the form
1 x cindicates that Bessie splashed a bucket of juice of color c on snowball x, coloring all snowballs in the subtree of x. A line of the form
2 xis a query for the sum of the colorfulness values of all snowballs in the subtree of x. Of course, 1 ≤ x ≤ N and 1 ≤ c ≤ 100000.
For each query of type 2, print the sum of colorfulness values within the corresponding subtree.
|1||20||1 ≤ N ≤ 100||1 ≤ Q ≤ 200|
|2||20||1 ≤ N ≤ 1000||1 ≤ Q ≤ 2000|
|3||60||1 ≤ N ≤ 100000||1 ≤ Q ≤ 100000|
5 18 1 2 1 3 3 4 3 5 1 4 1 2 1 2 2 2 3 2 4 2 5 1 5 1 2 1 2 2 2 3 2 4 2 5 1 1 1 2 1 2 2 2 3 2 4 2 5
1 0 1 1 0 2 0 2 1 1 5 1 3 1 1