SGAME  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
hide comments
nadstratosfer:
20171119 15:11:21
Very nice problem. Fun to revisit a puzzle that had bothered me since childhood and learn exactly when and why it can be solved or not. 

Rocker3011:
20130813 13:15:29
can't believe so many people says this problem belongs to tutorial. It does not, a simple backtracking would pass on a tutorial question but this required some graph theory and some optimization too. Awesome question :) 

mehmetin:
20130813 13:15:29
It would be better if it is stated that one edge will not be traversed twice. Last edit: 20121226 13:22:13 

Ankit Paharia:
20130813 13:15:29
If u say testcase is incorrect, then i should ask, is overwriting in a line allowed ???


Ankit Paharia:
20130813 13:15:29
problem description seems quite doubtful... what should be the output for this ...


Divanshu:
20130813 13:15:29
Does the figure need to be a closed one? It isn't specifically mentioned, though?


Anuraag:
20130813 13:15:29
Is the input always a connected graph??


RAJDEEP GUPTA:
20130813 13:15:29
I have one query:

Added by:  Swapnil R.Mehta 
Date:  20121212 
Time limit:  0.100s 
Source limit:  3000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  C C++ 4.3.2 CPP PASGPC PASFPC PYTHON PYTHON3 
Resource:  Own Problem 