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 int INF = 2e9;
const long long LINF = 4e18;
const long long MOD10[] = {1000000007, 1000000009, 1000000021, 1000000033,
                           1000000087, 1000000093, 1000000097, 1000000103,
                           1000000123, 1000000181, 1000000207, 1000000223,
                           1000000241, 1000000271, 1000000289, 1000000297,
                           1000000321, 1000000349, 1000000363, 1000000403};
const long long MOD19[] = {1900000043, 1900000097, 1900000111, 1900000117,
                           1900000129, 1900000139, 1900000237, 1900000253,
                           1900000303, 1900000381, 1900000387, 1900000429,
                           1900000433, 1900000441, 1900000493, 1900000517,
                           1900000519, 1900000547, 1900000567, 1900000601};
const long long MOD21[] = {2100000011, 2100000017, 2100000053, 2100000101,
                           2100000127, 2100000151, 2100000169, 2100000173,
                           2100000209, 2100000263, 2100000277, 2100000283,
                           2100000307, 2100000311, 2100000317, 2100000319,
                           2100000367, 2100000407, 2100000449, 2100000493};
vector<vector<int> > edge;
bool cut[int(0 + 100010)];
bool cut2[int(0 + 100010)];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  int a, b;
  cin >> n;
  edge.resize(n + 1);
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (edge[i].size() == 1) {
      a = edge[i][0];
      b = i;
      cut[b] = true;
      while (edge[a].size() <= 2) {
        if (edge[a].size() == 1) {
          cout << "Yes\n";
          return 0;
        }
        if (edge[a][0] == b) {
          b = edge[a][1];
        } else {
          b = edge[a][0];
        }
        cut[a] = true;
        swap(b, a);
      }
    }
  }
  vector<int> temp;
  fill(cut2, cut2 + 100010, 0);
  for (int i = 1; i <= n; i++) {
    if (cut[i]) {
      edge[i].clear();
    } else {
      temp.clear();
      for (auto x : edge[i]) {
        if (!cut[x]) {
          temp.push_back(x);
        }
      }
      swap(temp, edge[i]);
      if (temp.size() <= 3 && edge[i].size() == 1) {
        cut2[i] = true;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (cut2[i] || cut[i]) {
      edge[i].clear();
    } else {
      temp.clear();
      for (auto x : edge[i]) {
        if (!(cut2[x] || cut[x])) {
          temp.push_back(x);
        }
      }
      swap(temp, edge[i]);
      if (edge[i].size() >= 3) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
