#P9817. Magma Cave

Magma Cave

Magma Cave

Problem Description

Little Q is researching an active volcano. There are nn caves inside the volcano, labeled by 1,2,,n1,2,\dots,n. At the very beginning, before the first volcanic activity event, there is no magma path between these caves. You will be given qq operations, each operation is one of the following:

  • ''1 u v w\texttt{1 u v w}'' (1u,vn1 \leq u,v \leq n, uvu\neq v, 1wq1\leq w\leq q): A volcanic activity event comes such that a new magma path between the uu-th cave and the vv-th cave occurs, whose length is ww. Here ww is used for identifying the magma path, so ww will always be pairwise different.
  • ''2 k w\texttt{2 k w}'' (1k<n1 \leq k< n, 1wq1\leq w\leq q): Assume it is a undirected graph with nn vertices, each magma path denoting an edge, Little Q is wondering whether there exists a spanning tree whose kk-th shortest edge is of length ww. You are the partner of Little Q, please write a program to answer his question.

Input

The first line contains a single integer TT (1T1001 \leq T \leq 100), the number of test cases. For each test case: The first line contains two integers nn and qq (2n500002 \leq n \leq 50\,000, 1q2000001\leq q\leq 200\,000), denoting the number of caves and the number of operations. Each of the next qq lines describes an operation in formats described in the statement above. It is guaranteed that the sum of all nn is at most 300000300\,000, and the sum of all qq is at most 10000001\,000\,000.

Output

For each question, print a single line. If it is possible, print ''YES\texttt{YES}'', otherwise print ''NO\texttt{NO}''.

Sample Input

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

Sample Output

NO
YES
YES
NO
YES
YES

Source

2023“钉耙编程”中国大学生算法设计超级联赛(3)