#include using namespace std; using ll = long long; vector> g; int leaf1 = -1, leaf2 = -1; void dfs1(int v,int p = -1) { bool leaf = true; for(int u : g[v]) { if (u == p) continue; leaf = false; dfs1(u,v); } if (leaf) { if (leaf1 == -1) { leaf1 = v; } else if (leaf2 == -1) { leaf2 = v; } } } bool ok; int dfs2(int v, int p=-1) { int tmp = -1; for(int u : g[v]) { if (u == p) continue; int ret = dfs2(u,v); if (ret == -1) return -1; if (tmp == -1) { ret = tmp; } else if (ret != tmp) { ok = false; return -1; } } return tmp + 1; }; int main() { int n;cin >> n; g.resize(n); for(int i = 0; i < n-1;i++) { int a,b;cin >> a >> b; a--;b--; g[a].push_back(b); g[b].push_back(a); } dfs1(0); ok = true; dfs2(leaf1); if (!ok) { cout << "No" << endl; return 0; } ok = true; dfs2(leaf2); if (!ok) { cout << "No" << endl; } else { cout << "Yes" << endl; } return 0; }