时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
Alice is given a tree with
nodes indexed from
to
. Each edge on the tree can be either black or white, and all edges are initially white.
There are three kinds of operations:
1. Change the color of an edge to black.
2. Change the color of an edge to white.
3. Given a node index, count the sum of the number of black edges on the simple path from all odd-indexed nodes to that node.
Note that a simple path is a path between two nodes that does not visit any node more than once.
输入描述:
The first line contains two integers
and
, separated by a space. Here,
represents the number of nodes on the tree, and
represents the total number of operations.
Next, there are
lines, where the
-th line contains two integers
and
, representing the two nodes connected by the
-th edge on the tree. Following these are
lines, each representing one operation. The format of each operation is as follows:
- 1 x: Assign the color black to the edge indexed by
.
- 2 x: Assign the color white to the edge indexed by
.
- 3 x: Count the sum of the number of black edges on the simple path from all odd-indexed nodes to the node indexed by
.
输出描述:
For each operation 3, output a single integer in a line, indicating the sum of the number of black edges on the simple path from all odd-indexed nodes to the node indexed by
, where
is the parameter of the operation.
示例1
输入
复制
5 5
1 2
1 3
1 4
1 5
1 1
3 2
3 3
2 1
3 2
示例2
输入
复制
11 10
11 2
10 2
1 5
1 4
2 6
4 9
8 5
5 7
2 3
2 1
2 9
2 1
1 1
3 3
1 1
1 8
1 5
2 10
1 8
3 8