#include using namespace std; using ll = long long; vector bfs(vector> &E, int start){ int N = E.size(); int from, to; queue que; vector dist(N, 1e9); dist[start] = 0; que.push(start); while(!que.empty()){ from = que.front(); que.pop(); for (auto to : E[from]){ if (dist[to] != 1e9) continue; dist[to] = dist[from] + 1; que.push(to); } } return dist; } int main(){ int N, a, b, cnt=0, cnt2=0, d, e; cin >> N; vector deg(N); vector> E(N); for (int i=0; i> a >> b; a--; b--; deg[a]++; deg[b]++; E[a].push_back(b); E[b].push_back(a); } for (int i=0; i= 3){ cnt2++; d = deg[i]; e = i; } } if (cnt == 2){ cout << "Yes" << endl; return 0; } else if (cnt2 > 1){ cout << "No" << endl; return 0; } vector dist = bfs(E, e); vector v; for (int i=0; i