#P9817. Magma Cave
Magma Cave
Magma Cave
Problem Description
Little Q is researching an active volcano. There are caves inside the volcano, labeled by . At the very beginning, before the first volcanic activity event, there is no magma path between these caves. You will be given operations, each operation is one of the following:
- '''' (, , ): A volcanic activity event comes such that a new magma path between the -th cave and the -th cave occurs, whose length is . Here is used for identifying the magma path, so will always be pairwise different.
- '''' (, ): Assume it is a undirected graph with vertices, each magma path denoting an edge, Little Q is wondering whether there exists a spanning tree whose -th shortest edge is of length . You are the partner of Little Q, please write a program to answer his question.
Input
The first line contains a single integer (), the number of test cases. For each test case: The first line contains two integers and (, ), denoting the number of caves and the number of operations. Each of the next lines describes an operation in formats described in the statement above. It is guaranteed that the sum of all is at most , and the sum of all is at most .
Output
For each question, print a single line. If it is possible, print '''', otherwise print ''''.
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)