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;
const long double pi = 3.1415926535897932384626433832795l;
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 100100;
struct Input {
  int n;
  vector<int> a[N];
  bool read() {
    if (scanf("%d", &n) != 1) return 0;
    for (int i = int(0); i < int(n - 1); ++i) {
      int u, v;
      scanf("%d %d", &u, &v);
      u--, v--;
      a[u].push_back(v);
      a[v].push_back(u);
    }
    return 1;
  }
  void init(const Input& input) { *this = input; }
};
struct Data : Input {
  bool ok;
  void write() {
    if (ok) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
  virtual void solve() {}
  virtual void clear() { *this = Data(); }
};
struct Solution : Data {
  vector<int> st;
  void upd(int v, vector<int>& t, vector<int>& p, bool is) {
    if (!is) return;
    st.push_back(v);
    for (int i = int(0); i < int(t.size()); ++i) {
      if (t[i] == 2) {
        st.push_back(p[i]);
      }
    }
  }
  int calc(int v, int pr, bool is) {
    vector<int> t;
    vector<int> p;
    for (int i = int(0); i < int(a[v].size()); ++i) {
      int to = a[v][i];
      if (to == pr) continue;
      int k = calc(to, v, is);
      if (k < 0) {
        return -1;
      }
      t.push_back(k);
      p.push_back(to);
    }
    if (!t.size()) {
      return 0;
    }
    if (t.size() == 1) {
      if (t[0] == 0) {
        return 0;
      } else {
        return 2;
      }
    }
    if (t.size() == 2) {
      if (t[0] == 0 && t[1] == 0) {
        return 1;
      } else {
        if (t[0] == 2 && t[1] == 2 && pr >= 0) {
          upd(v, t, p, is);
          return -1;
        }
        return 2;
      }
    }
    int col = 0;
    for (int i = int(0); i < int(t.size()); ++i) {
      if (t[i] == 2) col++;
    }
    if (col > 3) {
      return -1;
    }
    if ((col > 2) || (col > 1 && pr >= 0)) {
      upd(v, t, p, is);
      return -1;
    } else {
      return 2;
    }
  }
  void solve() {
    int k = calc(0, -1, 1);
    if (k >= 0) {
      ok = 1;
      return;
    }
    for (int i = int(0); i < int(st.size()); ++i) {
      int k = calc(st[i], -1, 0);
      if (k >= 0) {
        ok = 1;
        return;
      }
    }
    ok = 0;
  }
  void clear() { *this = Solution(); }
};
Solution sol;
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  while (sol.read()) {
    sol.solve();
    sol.write();
    sol.clear();
  }
  return 0;
}
