Rikka with Graph II

Time Limit: 1000ms
Memory Limit: 65536KB
This problem will be judged on HDU. Original ID: 5424
64-bit integer IO format: %I64d      Java class name: Main

Description

As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:

Yuta has a non-direct graph with $n$ vertices and $n$ edges. Now he wants you to tell him if there exist a Hamiltonian path.

It is too difficult for Rikka. Can you help her?

Input

There are no more than 100 testcases.

For each testcase, the first line contains a number $n(1 \leq n \leq 1000)$.

Then $n$ lines follow. Each line contains two numbers $u,v(1 \leq u,v \leq n)$ , which means there is an edge between $u$ and $v$.

Output

For each testcase, if there exist a Hamiltonian path print "YES" , otherwise print "NO".

Sample Input

4
1 1
1 2
2 3
2 4
3
1 2
2 3
3 1

Sample Output

NO
YES

Hint
For the second testcase, One of the path is 1->2->3
If you doesn't know what is Hamiltonian path, click here (https://en.wikipedia.org/wiki/Hamiltonian_path).

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .