#include #include using namespace std; using ll=long long; using ull=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) using mll=atcoder::static_modint<1000000007>; int N; vector> E; vector D; int main(){ scanf("%d",&N); E.resize(N); rep(i,N-1){ int u,v; scanf("%d%d",&u,&v); u--; v--; E[u].push_back(v); E[v].push_back(u); } queue Q; D.assign(N,-1); rep(i,N) if(E[i].size()==1){ D[i]=0; Q.push(i); } while(Q.size()){ int p=Q.front(); Q.pop(); for(int e:E[p]) if(D[e]==-1){ D[e]=D[p]+1; Q.push(e); } } int maxD=0; rep(i,N) maxD=max(maxD,D[i]); bool ok=true; int centEdge=0; rep(p,N){ for(int e:E[p]) if(p>e) { int dD=abs(D[e]-D[p]); if(dD==1) continue; if(dD==0){ centEdge++; continue; } printf("No\n"); return 0; } } if(centEdge>1){ printf("No\n"); return 0; } if(centEdge==1) rep(i,N) if(E[i].size()>2){ printf("No\n"); return 0; } printf("Yes\n"); return 0; }