Graph
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Rose would like to find whether they truly love each other.
Rose lets Jack draw a graph of vertices, and Rose herself writes a set of vertex pair (u_i,v_i), named .
Initially the graph has no edge and is empty.
There are operations of 5 kinds, which are listed below:

  1. Jack adds edge into the graph. It is guaranteed that and are unreachable before adding.
  2. Jack deletes edge from the graph. It is guaranteed that this edge exists before deleting.
  3. Rose adds vertex pair into . It is guaranteed that is not in before adding.
  4. Rose deletes vertex pair (u,v) from . It is guaranteed that exists before deleting.
  5. Ask if they love each other, that is, whether every vertex pair in is reachable in the graph. In other words, whether for every vertex pair in , and are reachable in the graph.

输入描述:

The first line contains an integer  () --- the number of test cases.
The first line of each test case contains two integers (), () --- the number of vertices, the number of operations.
The next lines describe the operations, where the -th line contains three integers , , () for the first four operations and one integer for the last (fifth) kind of operation.
It is guaranteed that and .

输出描述:

For each operation of the fifth kind, output “YES” or “NO” in one line to indicate the answer, with the same order as the input.
示例1

输入

复制
1
5 10
5
3 2 5
4 2 5
1 4 5
2 4 5
5
1 1 2
3 1 5
4 1 5
2 1 2

输出

复制
YES
YES