Limak is a little bear who learns to draw. People usually start with houses, fences and flowers but why would bears do it? Limak lives in the forest and he decides to draw a tree.

Recall that tree is a connected graph consisting of n vertices and n - 1 edges.

Limak chose a tree with n vertices. He has infinite strip of paper with two parallel rows of dots. Little bear wants to assign vertices of a tree to some n distinct dots on a paper so that edges would intersect only at their endpoints — drawn tree must be planar. Below you can see one of correct drawings for the first sample test.

<image>

Is it possible for Limak to draw chosen tree?

Input

The first line contains single integer n (1 ≤ n ≤ 105).

Next n - 1 lines contain description of a tree. i-th of them contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) denoting an edge between vertices ai and bi. It's guaranteed that given description forms a tree.

Output

Print "Yes" (without the quotes) if Limak can draw chosen tree. Otherwise, print "No" (without the quotes).

Examples

Input

8
1 2
1 3
1 6
6 4
6 7
6 5
7 8


Output

Yes


Input

13
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9
3 10
4 11
4 12
4 13


Output

No
#include <bits/stdc++.h>
using namespace std;
long long dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long dy[8] = {1, 0, -1, 0, -1, 1, 1, -1};
class pa3 {
 public:
  long long x;
  long long y, z;
  pa3(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {}
  bool operator<(const pa3& p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    return z < p.z;
  }
  bool operator>(const pa3& p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    return z > p.z;
  }
  bool operator==(const pa3& p) const {
    return x == p.x && y == p.y && z == p.z;
  }
  bool operator!=(const pa3& p) const {
    return !(x == p.x && y == p.y && z == p.z);
  }
};
class pa4 {
 public:
  long long x;
  long long y, z, w;
  pa4(long long x = 0, long long y = 0, long long z = 0, long long w = 0)
      : x(x), y(y), z(z), w(w) {}
  bool operator<(const pa4& p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    if (z != p.z) return z < p.z;
    return w < p.w;
  }
  bool operator>(const pa4& p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    if (z != p.z) return z > p.z;
    return w > p.w;
  }
  bool operator==(const pa4& p) const {
    return x == p.x && y == p.y && z == p.z && w == p.w;
  }
};
class pa2 {
 public:
  long long x, y;
  pa2(long long x = 0, long long y = 0) : x(x), y(y) {}
  pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); }
  pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); }
  bool operator<(const pa2& p) const { return y != p.y ? y < p.y : x < p.x; }
  bool operator>(const pa2& p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const pa2& p) const {
    return abs(x - p.x) == 0 && abs(y - p.y) == 0;
  }
  bool operator!=(const pa2& p) const {
    return !(abs(x - p.x) == 0 && abs(y - p.y) == 0);
  }
};
string itos(long long i) {
  ostringstream s;
  s << i;
  return s.str();
}
long long Gcd(long long v, long long b) {
  if (v == 0) return b;
  if (b == 0) return v;
  if (v > b) return Gcd(b, v);
  if (v == b) return b;
  if (b % v == 0) return v;
  return Gcd(v, b % v);
}
long long mod;
long long extgcd(long long a, long long b, long long& x, long long& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
pair<long long, long long> operator+(const pair<long long, long long>& l,
                                     const pair<long long, long long>& r) {
  return {l.first + r.first, l.second + r.second};
}
pair<long long, long long> operator-(const pair<long long, long long>& l,
                                     const pair<long long, long long>& r) {
  return {l.first - r.first, l.second - r.second};
}
ostream& operator<<(ostream& os, const vector<long long>& VEC) {
  for (auto v : VEC) os << v << " ";
  return os;
}
ostream& operator<<(ostream& os, const pair<long long, long long>& PAI) {
  os << PAI.first << " : " << PAI.second;
  return os;
}
ostream& operator<<(ostream& os, const pa3& PAI) {
  os << PAI.x << " : " << PAI.y << " : " << PAI.z;
  return os;
}
ostream& operator<<(ostream& os, const pa4& PAI) {
  os << PAI.x << " : " << PAI.y << " : " << PAI.z << " : " << PAI.w;
  return os;
}
ostream& operator<<(ostream& os,
                    const vector<pair<long long, long long> >& VEC) {
  for (auto v : VEC) os << v << " ";
  return os;
}
long long beki(long long wa, long long rr, long long warukazu) {
  if (rr == 0) return 1 % warukazu;
  if (rr == 1) return wa % warukazu;
  wa %= warukazu;
  if (rr % 2 == 1)
    return ((long long)beki(wa, rr - 1, warukazu) * (long long)wa) % warukazu;
  long long zx = beki(wa, rr / 2, warukazu);
  return (zx * zx) % warukazu;
}
long long pr[1100000];
long long inv[1100000];
long long comb(long long nn, long long rr) {
  if (rr < 0 || rr > nn || nn < 0) return 0;
  long long r = pr[nn] * inv[rr];
  r %= mod;
  r *= inv[nn - rr];
  r %= mod;
  return r;
}
void gya(long long ert) {
  pr[0] = 1;
  for (long long i = 1; i <= ert; i++) {
    pr[i] = ((long long)pr[i - 1] * i) % mod;
  }
  inv[ert] = beki(pr[ert], mod - 2, mod);
  for (long long i = ert - 1; i >= 0; i--) {
    inv[i] = (long long)inv[i + 1] * (i + 1) % mod;
  }
}
vector<long long> G[100020];
long long d[100020];
long long dp[20][100020];
long long cnt = 0;
long long ju[100200];
void dfs(long long r, long long p, long long di = 0) {
  d[r] = di;
  dp[0][r] = p;
  ju[r] = cnt;
  cnt++;
  for (auto v : G[r])
    if (v != p) dfs(v, r, di + 1);
}
bool hik(long long x, long long y) { return ju[x] < ju[y]; }
long long lca(long long a, long long b) {
  if (d[a] < d[b]) swap(a, b);
  long long sa = d[a] - d[b];
  for (long long i = 0; i < 20; i++)
    if (sa & (1 << i)) a = dp[i][a];
  if (a == b) return a;
  for (long long i = 19; i >= 0; i--) {
    if (dp[i][a] != dp[i][b]) {
      a = dp[i][a];
      b = dp[i][b];
    }
  }
  return dp[0][a];
}
long long a[100020] = {};
void nu(long long x, long long p) {
  if (a[x]) return;
  a[x] = 1;
  if (x == p) return;
  nu(dp[0][x], p);
}
long long oya[100020];
void dfs2(long long r, long long p, long long di = 0) {
  d[r] = di;
  oya[r] = p;
  for (auto v : G[r])
    if (v != p)
      if (a[v]) dfs2(v, r, di + 1);
}
long long b[100020] = {};
long long c[100020] = {};
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long y, yy;
    cin >> y >> yy;
    y--, yy--;
    G[y].push_back(yy);
    G[yy].push_back(y);
  }
  dfs(0, 0);
  vector<long long> ve;
  for (long long i = 0; i < n; i++)
    if (G[i].size() >= 3) ve.push_back(i);
  sort(ve.begin(), ve.end(), hik);
  if (ve.size() <= 2) {
    cout << "Yes" << endl;
    return;
  }
  for (long long i = 0; i < 20 - 1; i++)
    for (long long j = 0; j < n; j++) dp[i + 1][j] = dp[i][dp[i][j]];
  long long l = lca(ve[0], ve.back());
  for (auto v : ve) nu(v, l);
  dfs2(l, l, 0);
  long long le = -1, id = -1;
  for (long long i = 0; i < n; i++)
    if (a[i]) {
      if (d[i] > le) {
        le = d[i], id = i;
      }
    }
  dfs2(id, id, 0);
  le = -1, id = -1;
  for (long long i = 0; i < n; i++)
    if (a[i]) {
      if (d[i] > le) {
        le = d[i], id = i;
      }
    }
  vector<long long> ch;
  ch.push_back(id);
  while (1) {
    long long g = oya[ch.back()];
    if (ch.back() == g) break;
    ch.push_back(g);
  }
  assert(ch.size() == le + 1);
  for (long long i = 0; i < ch.size(); i++) {
    b[ch[i]] = 1;
    long long mae = -1;
    if (i) mae = ch[i - 1];
    long long ato = -1;
    if (i + 1 < ch.size()) ato = ch[i + 1];
    for (auto v : G[ch[i]])
      if (a[v]) {
        b[v] = 1;
        if (G[v].size() > 3 && v != mae && v != ato) c[i]++;
      }
  }
  for (long long i = 0; i < n; i++)
    if (a[i]) {
      if (!b[i]) {
        cout << "No" << endl;
        return;
      }
    }
  if (ch.size() <= 2) {
    cout << "Yes" << endl;
    return;
  }
  if (ch.size() == 3) {
    long long e = 0;
    if (G[ch[0]].size() > 3) e++;
    if (G[ch[2]].size() > 3) e++;
    if (c[1] + e >= 3) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
    return;
  } else {
    l = ch.size();
    for (long long i = 2; i < l - 2; i++) {
      if (c[i]) {
        cout << "No" << endl;
        return;
      }
    }
    long long e = c[1];
    if (G[ch[0]].size() > 3) e++;
    long long ee = c[l - 2];
    if (G[ch[l - 1]].size() > 3) ee++;
    if (e > 1 || ee > 1) {
      cout << "No" << endl;
    } else
      cout << "Yes" << endl;
  }
}
signed main() {
  mod = 1000000007;
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n = 1;
  for (long long i = 0; i < n; i++) solve();
  return 0;
}
