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 N = 1e5 + 1123;
vector<int> v[N], np[N];
bool saf[N], flag;
int b[N], r;
bool dfsS(int x, int par) {
  bool saf2 = true;
  for (auto u : v[x])
    if (u != par) saf2 &= dfsS(u, x);
  if (v[x].size() > 2)
    saf[x] = false;
  else
    saf[x] = saf2;
  return saf[x];
}
bool dfsR(int x, int par, bool safP) {
  int cnt = 0, nasaf = 0, nasafV = -1;
  for (auto u : v[x])
    if (u != par) {
      bool ch = (v[x].size() == 2);
      if (x == 0) {
        if (v[x].size() > 2)
          ch = false;
        else if (v[x].size() == 1)
          ch = true;
        else if ((u != v[x][0] && saf[v[x][0]]) ||
                 (u != v[x][1] && saf[v[x][1]]))
          ch = true;
        else
          ch = false;
      }
      if (dfsR(u, x, ch)) {
        b[x]++;
        np[x].push_back(u);
      }
    }
  for (auto u : v[x])
    if (u != par) {
      cnt += saf[u];
      if (!saf[u]) {
        cnt += 5;
        nasaf++;
        nasafV = u;
      }
    }
  if (x) nasaf += !safP;
  if (v[x].size() > 3) {
    for (auto u : v[x])
      if (u != par) {
        b[u]++;
        np[u].push_back(x);
      }
  } else if (nasaf)
    for (auto u : v[x])
      if (u != par) {
        if (nasaf > 1)
          b[u]++;
        else
          b[u] += (nasafV != u);
      }
  return cnt > 2;
}
bool dfsN(int x, int par) {
  if (!flag) return false;
  int cnt = 0;
  for (auto u : v[x])
    if (u != par) cnt += dfsN(u, x);
  if (x != r && cnt > 1) flag = false;
  if (cnt) return true;
  bool flag2 = true;
  int cnt2 = 0;
  for (auto u : v[x])
    if (u != par) {
      cnt2++;
      if (v[u].size() > 2) flag2 = false;
    }
  if (!flag2 || cnt2 > 2) return true;
  return false;
}
void work(int x) {
  flag = true;
  dfsN(x, -1);
  if (flag) {
    cout << "Yes\n";
    exit(0);
  }
}
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfsS(0, -1);
  dfsR(0, -1, true);
  int r2 = -1;
  for (int i = 0; i < n; i++) {
    if (b[i] > r2 && b[i] <= 2) {
      r = i;
      r2 = b[i];
    }
  }
  work(r);
  cout << "No" << endl;
  return 0;
}
