spoj#SGAME. SHAPE GAME

SHAPE GAME

You probably might have played the game of constructing a figure without lifting up the pencil.But it seems too easy for us.
Let's add some twist to it!
What about start constructing a figure from a point and returning to the same point resulting in the figure without lifting up the pencil.

Note: Figure is bounded and one can't retrace an arc or line.

 

INPUT SPECIFICATION

Input consists of several test data.There are 't' test cases. For each case you are given the point index 'n' from which to start and end.Then follows two space separated index that define a line from index 'i' to index 'j'.These integers follow up until "-1 -1" is encountered.

 

OUTPUT SPECIFICATION

Output "YES", if it's possible to construct figure satisfying the specification and "NO" if it's not possible (without quotes).

 

CONSTRAINTS

t<=100
1<=n<=300
1<=i,j<=300
i!=j

 

EXAMPLE

Sample Input:

1 1 1 2 1 4 2 3 2 5 2 6 3 6 4 7 5 6 6 7 -1 -1

Sample Output:

YES

</p>