| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 | 2048 MB | 1 | 1 | 1 | 100.000% |
You are given a tree. The tree has $n$ vertices, labeled from 1ドル$ to $n$.
Let us denote the path between vertices $a$ and $b$ as $(a, b)$. Let the $d$-set of a path be the set of vertices on the tree located within a distance $\le d$ from at least one vertex of the path. For example, the 0ドル$-set of a path is the set of its vertices. The distance between vertices is the number of edges on the path between these vertices.
Let $S$ be a multiset of tree paths. Initially, $S$ is empty. Your task is to process the following queries:
1 $u$ $v$": add path $(u, v)$ into $S$ (1ドル \le u, v \le n$).2 $u$ $v$": delete a single path $(u, v)$ from $S$ (1ドル \le u, v \le n$). Note that $(u, v)$ and $(v, u)$ denote the same path. For example, if $S=\{(2, 3), (2, 3)\},ドル then after a query "2 3 2", we will have $S=\{(2, 3)\}$. Before this query, it is guaranteed that at least one path $(u, v)$ or $(v, u)$ is present in $S$.3 $d$": print the size of intersection of $d$-sets of all paths from $S$ (0ドル \le d \le n$). If $S$ is empty, print 0ドル$.The first line contains an integer $t,ドル the number of test cases (1ドル \le t \le 10^4$). The test cases follow.
The first line of each test case contains two integers $n$ and $q$ (1ドル \le n, q \le 10^5$), the number of vertices in the tree and the number of queries.
Each of the following $n - 1$ lines contains two integers $u_i$ and $v_i$: indices of vertices connected by the $i$-th edge of the tree (1ドル \le u_i, v_i \le n$).
The following $q$ lines contain queries in the format described in the statement.
The sum of $n$ over all test cases does not exceed 10ドル^5$. The sum of $q$ over all test cases does not exceed 10ドル^5$.
For each query of the third type, output a single line with the answer.
1 8 7 1 2 1 3 3 4 2 5 4 6 1 7 6 8 3 1 1 7 8 3 1 2 7 8 1 8 6 1 7 7 3 3
0 7 3