#P1464F. My Beautiful Madness

    ID: 986 Type: RemoteJudge 2000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>data structurestrees*3500

My Beautiful Madness

No submission language available for this problem.

Description

You are given a tree. We will consider simple paths on it. Let's denote path between vertices aa and bb as (a,b)(a, b). Let dd-neighborhood of a path be a set of vertices of the tree located at a distance d\leq d from at least one vertex of the path (for example, 00-neighborhood of a path is a path itself). Let PP be a multiset of the tree paths. Initially, it is empty. You are asked to maintain the following queries:

  • 11 uu vv — add path (u,v)(u, v) into PP (1u,vn1 \leq u, v \leq n).
  • 22 uu vv — delete path (u,v)(u, v) from PP (1u,vn1 \leq u, v \leq n). Notice that (u,v)(u, v) equals to (v,u)(v, u). For example, if P={(1,2),(1,2)}P = \{(1, 2), (1, 2)\}, than after query 22 22 11, P={(1,2)}P = \{(1, 2)\}.
  • 33 dd — if intersection of all dd-neighborhoods of paths from PP is not empty output "Yes", otherwise output "No" (0dn10 \leq d \leq n - 1).

The first line contains two integers nn and qq — the number of vertices in the tree and the number of queries, accordingly (1n21051 \leq n \leq 2 \cdot 10^5, 2q21052 \leq q \leq 2 \cdot 10^5).

Each of the following n1n - 1 lines contains two integers xix_i and yiy_i — indices of vertices connected by ii-th edge (1xi,yin1 \le x_i, y_i \le n).

The following qq lines contain queries in the format described in the statement.

It's guaranteed that:

  • for a query 22 uu vv, path (u,v)(u, v) (or (v,u)(v, u)) is present in PP,
  • for a query 33 dd, PP \neq \varnothing,
  • there is at least one query of the third type.

For each query of the third type output answer on a new line.

Input

The first line contains two integers nn and qq — the number of vertices in the tree and the number of queries, accordingly (1n21051 \leq n \leq 2 \cdot 10^5, 2q21052 \leq q \leq 2 \cdot 10^5).

Each of the following n1n - 1 lines contains two integers xix_i and yiy_i — indices of vertices connected by ii-th edge (1xi,yin1 \le x_i, y_i \le n).

The following qq lines contain queries in the format described in the statement.

It's guaranteed that:

  • for a query 22 uu vv, path (u,v)(u, v) (or (v,u)(v, u)) is present in PP,
  • for a query 33 dd, PP \neq \varnothing,
  • there is at least one query of the third type.

Output

For each query of the third type output answer on a new line.

Samples

Sample Input 1

1 4
1 1 1
1 1 1
2 1 1
3 0

Sample Output 1

Yes

Sample Input 2

5 3
1 2
1 3
3 4
4 5
1 1 2
1 5 5
3 1

Sample Output 2

No

Sample Input 3

10 6
1 2
2 3
3 4
4 7
7 10
2 5
5 6
6 8
8 9
1 9 9
1 9 8
1 8 5
3 0
3 1
3 2

Sample Output 3

No
Yes
Yes