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;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using ll = long long;
using llu = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vll = vector<ll>;
using vvll = vector<vll>;
const int INF = numeric_limits<int>::max();
const double EPS = 1e-10;
struct node;
struct edge;
using pnode = shared_ptr<node>;
using pedge = shared_ptr<edge>;
using graph = vector<pnode>;
struct node {
  bool visited;
  vector<pedge> adjusted;
  ll k = 0;
  ll id, leafs = 0, depth = 0;
  bool top;
  pedge to_parent;
};
struct edge {
  pnode to, from;
  ll leafs = 0;
  pedge opposite;
};
void connect(pnode &a, pnode &b) {
  pedge ea = make_shared<edge>();
  pedge eb = make_shared<edge>();
  ea->from = a;
  ea->to = b;
  ea->opposite = eb;
  eb->from = b;
  eb->to = a;
  eb->opposite = ea;
  a->adjusted.emplace_back(ea);
  b->adjusted.emplace_back(eb);
  a->k++;
  b->k++;
}
ll dfs(pnode u) {
  u->visited = true;
  int l = 0;
  for (auto e : u->adjusted) {
    auto v = e->to;
    if (v->visited) continue;
    v->to_parent = e;
    e->leafs = dfs(v);
    l += e->leafs;
  }
  return max(1, l);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  while (cin >> n) {
    vector<pnode> g(n);
    for (ll i = 0; i < n; i++) {
      g[i] = make_shared<node>();
      g[i]->id = i + 1;
    }
    for (ll i = 0; i < n - 1; i++) {
      ll a, b;
      cin >> a >> b;
      a--;
      b--;
      connect(g[a], g[b]);
    }
    ll leafs;
    queue<pnode> q;
    for (auto u : g) {
      if (u->adjusted.size() == 1) {
        q.emplace(u);
        u->visited = true;
        u->leafs = 1;
      }
    }
    leafs = q.size();
    while (!q.empty()) {
      auto u = q.front();
      q.pop();
      for (auto e : u->adjusted) {
        auto v = e->to;
        if (v->visited) continue;
        e->opposite->leafs = u->leafs;
        v->leafs += u->leafs;
        v->k--;
        if (v->k == 1) {
          q.emplace(v);
          v->visited = true;
        }
      }
    }
    for (auto u : g) {
      ll big = 0;
      u->visited = false;
      for (auto e : u->adjusted) {
        if (e->leafs == 0) e->leafs = leafs - u->leafs;
        if (e->leafs > 1) big++;
      }
      u->top = (u->adjusted.size() > 3 || big > 1);
    }
    pnode bottom;
    g[0]->visited = true;
    g[0]->depth = 0;
    q.emplace(g[0]);
    while (!q.empty()) {
      auto u = q.front();
      q.pop();
      for (auto e : u->adjusted) {
        auto v = e->to;
        if (v->visited) continue;
        v->visited = true;
        v->depth = u->depth + 1;
        v->to_parent = e;
        if (v->top) bottom = v;
        q.emplace(v);
      }
    }
    bool ok = true;
    for (auto u : g) u->visited = false;
    if (bottom) {
      while (bottom->to_parent) {
        bottom->visited = true;
        bottom = bottom->to_parent->from;
      }
      bottom->visited = true;
      bottom.reset();
      for (auto u : g) {
        if (!u->top || u->visited) continue;
        if (!bottom || u->depth > bottom->depth) bottom = u;
      }
      if (bottom) {
        while (!bottom->visited) {
          bottom->visited = true;
          bottom = bottom->to_parent->from;
        }
        while (bottom->to_parent) {
          bottom = bottom->to_parent->from;
          if (bottom->top) ok = false;
        }
        for (auto u : g) ok = ok && (u->visited || !u->top);
      }
    }
    if (ok) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
