Hit the road!
There is an undirected tree consisting of vertices connected by two-sided edge. There is also a train located inside this tree. The head of the train is at the top of and the tail is at the top of . The train cars occupy all the vertices on the simple path between the vertices and .
You want to find out if the train can turn around, that is, move the head to the vertex where the tail was and move the tail to the vertex where the head was. Unfortunately, train movements are limited by the tree structure.
In one operation, the train can move its head to a neighboring vertex that is not currently occupied by the train. When this happens, the tail of the train moves one vertex closer to the head, meaning the length of the train does not change. Similarly, the train can move the tail to a neighboring vertex that is not currently occupied by the train. When this happens, the head of the train moves one vertex closer to the tail.
Determine if the train will be able to turn around using some sequence of operations.
Input
The first line contains a single integer — the number of input data sets. The following lines contain descriptions of input data sets.
The first line of each data set contains three integers .
Each of the following lines contains two integers denoting an edge between the vertices and . It is guaranteed that these edges form a tree.
It is guaranteed that the sum of for all input data sets does not exceed .
Output
For each set of input data, output "YES" if the train can turn around and "NO" otherwise.