#include <iostream>
#include <queue>
#include <vector>
#include<algorithm>
using namespace std;
bool valid;
void dfs(int node, vector<vector<int>> & graph, vector<int> & color){
for(int child : graph[node]){
if(color[node] == color[child])
valid = false;
if(color[child] == -1){
color[child] = !color[node];
dfs(child, graph, color);
}
}
}
int main(){
int nodes, from, to;
while(cin >> nodes){
valid = true;
if(nodes == 0)
break;
vector<vector<int>> graph(nodes + 1);
vector<int> color(nodes + 1, -1);
while(cin >> from >> to){
if(from == 0 && to == 0)
break;
graph[from].push_back(to);
graph[to].push_back(from);
}
for(int node = 1; node <= nodes; ++node){
if(color[node] == -1){
color[node] = 1;
dfs(node, graph, color);
}
}
if(valid)
cout <<"YES\n";
else
cout <<"NO\n";
}
/* */
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmJvb2wgdmFsaWQ7CnZvaWQgZGZzKGludCBub2RlLCB2ZWN0b3I8dmVjdG9yPGludD4+ICYgZ3JhcGgsIHZlY3RvcjxpbnQ+ICYgY29sb3IpewogICAgZm9yKGludCBjaGlsZCA6IGdyYXBoW25vZGVdKXsKICAgICAgICBpZihjb2xvcltub2RlXSA9PSBjb2xvcltjaGlsZF0pCiAgICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgIAogICAgICAgIGlmKGNvbG9yW2NoaWxkXSA9PSAtMSl7CiAgICAgICAgICAgIGNvbG9yW2NoaWxkXSA9ICFjb2xvcltub2RlXTsKICAgICAgICAgICAgZGZzKGNoaWxkLCBncmFwaCwgY29sb3IpOwogICAgICAgIH0KICAgIH0KCiAgICAKICAgIAp9CmludCBtYWluKCl7CgogICAgaW50IG5vZGVzLCBmcm9tLCB0bzsKICAgIAogICAgd2hpbGUoY2luID4+IG5vZGVzKXsKICAgICAgICB2YWxpZCA9IHRydWU7CiAgICAgICAgaWYobm9kZXMgPT0gMCkKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgdmVjdG9yPHZlY3RvcjxpbnQ+PiBncmFwaChub2RlcyArIDEpOwogICAgICAgIHZlY3RvcjxpbnQ+IGNvbG9yKG5vZGVzICsgMSwgLTEpOwogICAgICAgIAogICAgICAgIHdoaWxlKGNpbiA+PiBmcm9tID4+IHRvKXsKICAgICAgICAgICAgaWYoZnJvbSA9PSAwICYmIHRvID09IDApCiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgCiAgICAgICAgICAgIGdyYXBoW2Zyb21dLnB1c2hfYmFjayh0byk7CiAgICAgICAgICAgIGdyYXBoW3RvXS5wdXNoX2JhY2soZnJvbSk7CiAgICAgICAgICAgIAogICAgICAgIH0KICAgICAgICBmb3IoaW50IG5vZGUgPSAxOyBub2RlIDw9IG5vZGVzOyArK25vZGUpewogICAgICAgICAgICBpZihjb2xvcltub2RlXSA9PSAtMSl7CiAgICAgICAgICAgICAgICBjb2xvcltub2RlXSA9IDE7CiAgICAgICAgICAgICAgICBkZnMobm9kZSwgZ3JhcGgsIGNvbG9yKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZih2YWxpZCkKICAgICAgICAgICAgY291dCA8PCJZRVNcbiI7CiAgICAgICAgZWxzZSAKICAgICAgICAgICAgY291dCA8PCJOT1xuIjsKICAgIH0KCi8qICovCn0=