#include <bits/stdc++.h>
using namespace std;
int MAX_V, a, b, *pre, cnt, ans, *visit;
stack<pair<int , int> >s;
void init()
{
cnt = 0;
pre = new int [MAX_V + 5];
visit = new int [MAX_V + 5];
for (int i = 1; i <= MAX_V; i++)
pre[i] = i, visit[i] = 0;
}
int find(int x)
{
if (x != pre[x]) pre[x] = find(pre[x]);
return pre[x];
}
bool Iunion(int x, int y)
{
visit[x] = 1, visit[y] = 1;
x = find(x);
y = find(y);
if (x == y) return false;
else return pre[x] = y, ++cnt;
}
int main(int argc, char const *argv[])
{
while (cin >> a >> b && a != -1 && b != -1)
{
if (a == 0 && b == 0) {cout << "Yes" << endl; continue;}
MAX_V = max(a, b);
s.push(make_pair(a, b));
while (cin >> a >> b && a && b)
{
MAX_V = max(MAX_V, max(a, b));
s.push(make_pair(a, b));
}
init();
while (s.size())
{
pair<int , int >pii = s.top();
ans = Iunion(pii.first, pii.second);
if (!ans) break;
s.pop();
}
for (int i = 1; i <= MAX_V; i++)
if (visit[i]) cnt--;
if (ans && cnt == -1) cout << "Yes" << endl;
else cout << "No" << endl;
while (s.size()) s.pop();
delete[] pre;
}
return 0;
}
#include using namespace std;int MAX_V, a, b, *pre, cnt, ans, *visit;stack >s;void init(){ cnt = 0; pre = new int [MAX_V + 5]; visit = new int [MAX_V + 5]; for (int i = 1; i <= MAX_V; i++)