Road
In one country, there are cities, numbered to . A civil engineer has to build public roads that connect all the cities together, i.e. it must be possible to travel from all cities to any other cities, maybe going through multiple cities. His team has surveyed several routes (candidate road between any two cities). Each route is a bidirectional connection between two cities. He can build a bidirectional road on the surveyed route for a specific cost (The shorter the route is the cheaper the road).
This engineer has never planned a road system in advance. He would just pick one of the routes based on his preference, and build a road until all the cities are connected.
Right now this engineer is going to build a road from the city to the city . With pressure from the government to reduce the cost, he asks you to write a program to decide, if he should build this road or not. Your program should say "YES" if the building of this road guaranteed that it can be part of the shortest road system that connects all cities together. Otherwise, your program should say "NO".
Input
The first line is a number of test cases .
Each test case starts with a line contains integers and . Here is the number of cities in this road system, is the number of surveyed routes, and indicate the route between two cities, that the engineer asks if he can build a road or not.
Then, the each of the following lines contains numbers and indicates that there are the bidirectional route of length between and . The length of each road in the current system is unique. And, there is only one possible road between two cities. The input guarantees that at least one road system has a route between any two cities. All numbers are integer.
Output
For each test case, display "YES" if the engineer can build a road as part of the shortest road system. Otherwise, print "NO".