#include using namespace std; #include using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); i++) #define REP(i,a,b) for(int i=(a);i<(b);i++) #define all(v) begin(v),end(v) #define rall(v) rbegin(v),rend(v) #define fi first #define se second #define re0 return 0 template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } using ll = long long; using pii = pair; using pll = pair; constexpr ll inf = 2e9; constexpr ll llinf = 9e18; //constexpr ll MOD = 998244353; constexpr ll MOD = 1000000007; const double pai=acos(-1); int main() { //cout<>n; vector> g(n); rep(i,n-1){ int a,b;cin>>a>>b; a--;b--; g[a].push_back(b); g[b].push_back(a); } int tmp=0,id; rep(i,n){ int a=g[i].size(); if(a>tmp){ tmp=a; id=i; } } if(tmp==1||tmp==2){ cout<<"Yes"< vec(n),vec1(n); vector d(n,-1); queue que; d[id]=0; que.push(id); while(!que.empty()){ int v=que.front();que.pop(); for(auto u:g[v]){ if(d[u]!=-1)continue; d[u]=d[v]+1; que.push(u); if(g[u].size()==1)vec[u]=1,vec1[v]++; } } //rep(i,n)cout< st; rep(i,n){ if(vec[i])st.insert(d[i]); } bool ok=true; if(st.size()!=1)ok=false; rep(i,n){ for(auto u:g[i]){ if(vec[i]&&vec1[u]>1&&u!=id)ok=false; } } if(ok)cout<<"Yes"<