AT_abc420_e [ABC420E] Reachability Query

Description

You are given an undirected graph with $ N $ vertices and zero edges. The vertices are numbered $ 1,2,\dots,N $ , and initially all vertices are white. Process a total of $ Q $ queries of the following three types: - Type $ 1 $ : Add an undirected edge connecting vertices $ u $ and $ v $ . - Type $ 2 $ : If vertex $ v $ is white, change it to black; if it is black, change it to white. - Type $ 3 $ : Determine whether a black vertex can be reached from vertex $ v $ by traversing zero or more edges; report `Yes` if reachable, and `No` otherwise.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ Q $ $ \rm{Query} $ $ _1 $ $ \rm{Query} $ $ _2 $ $ \vdots $ $ \rm{Query} $ $ _Q $ where $ \rm{Query} $ $ _i $ represents the $ i $ -th query. Type $ 1 $ queries are given in the following format: > 1 $ u $ $ v $ Type $ 2 $ queries are given in the following format: > 2 $ v $ Type $ 3 $ queries are given in the following format: > 3 $ v $

Output Format

For each type $ 3 $ query, output the answer as follows: - `Yes` if a black vertex can be reached from vertex $ v $ by traversing zero or more edges; - `No` if no black vertex can be reached from vertex $ v $ by traversing zero or more edges.

Explanation/Hint

### Sample Explanation 1 In this input, the graph initially has five vertices and zero edges. This input contains $ 12 $ queries. - The 1st query is `3 2`. - At this point, no black vertex can be reached from vertex $ 2 $ by traversing zero or more edges, so report `No`. - The 2nd query is `2 2`. - Vertex $ 2 $ is white, so change it to black. - The 3rd query is `3 2`. - At this point, black vertex $ 2 $ can be reached from vertex $ 2 $ by traversing zero or more edges. Therefore, report `Yes`. - The 4th query is `1 2 5`. - Add an edge connecting vertices $ 2,5 $ . - The 5th query is `1 3 4`. - Add an edge connecting vertices $ 3,4 $ . - The 6th query is `3 4`. - At this point, no black vertex can be reached from vertex $ 4 $ by traversing zero or more edges, so report `No`. - The 7th query is `3 5`. - At this point, black vertex $ 2 $ can be reached from vertex $ 5 $ by traversing zero or more edges. Therefore, report `Yes`. - The 8th query is `1 4 5`. - Add an edge connecting vertices $ 4,5 $ . - The 9th query is `1 1 3`. - Add an edge connecting vertices $ 1,3 $ . - The 10th query is `3 1`. - At this point, black vertex $ 2 $ can be reached from vertex $ 1 $ by traversing zero or more edges. Therefore, report `Yes`. - The 11th query is `2 2`. - Vertex $ 2 $ is black, so change it to white. - The 12th query is `3 1`. - At this point, no black vertex can be reached from vertex $ 1 $ by traversing zero or more edges, so report `No`. ### Constraints - All input values are integers. - $ 1 \le N \le 2 \times 10^5 $ - $ 1 \le Q \le 6 \times 10^5 $ - Type $ 1 $ queries satisfy the following constraints: - $ 1 \le u < v \le N $ - For each query, no edge connecting $ u $ and $ v $ has been added before that query. - Type $ 2,3 $ queries satisfy the following constraints: - $ 1 \le v \le N $