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;
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline string tostr(const T &x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
inline long long parse(const string &s) {
  stringstream ss(s);
  long long x;
  ss >> x;
  return x;
}
const double EPS = 1e-12;
const int INF = 1000 * 1000 * 1000;
const long long LINF = INF * 1ll * INF;
const double DINF = 1e200;
const double PI = 3.1415926535897932384626433832795l;
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
long long powmod(long long a, long long p, long long m) {
  long long r = 1;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
bool isprime(long long a) {
  for (long long i = 2; i * i <= a; ++i) {
    if (a % i == 0) return false;
  }
  return true;
}
long long sqrtup(long long a) {
  if (!a) return 0;
  long long x = max(0ll, (long long)sqrt((double)a));
  while (x * x >= a) --x;
  while ((x + 1) * (x + 1) < a) ++x;
  return x + 1;
}
long long sqrtdown(long long a) {
  long long x = max(0ll, (long long)sqrt((double)a));
  while (x * x > a) --x;
  while ((x + 1) * (x + 1) <= a) ++x;
  return x;
}
template <class T>
ostream &operator<<(ostream &s, const vector<T> &v);
template <class A, class B>
ostream &operator<<(ostream &s, const pair<A, B> &p);
template <class K, class V>
ostream &operator<<(ostream &s, const map<K, V> &m);
template <class T, size_t N>
ostream &operator<<(ostream &s, const array<T, N> &a);
template <class T>
ostream &operator<<(ostream &s, const vector<T> &v) {
  s << '[';
  for (int i = 0; i < (((int)(v).size())); ++i) {
    if (i) s << ',';
    s << v[i];
  }
  s << ']';
  return s;
}
template <class A, class B>
ostream &operator<<(ostream &s, const pair<A, B> &p) {
  s << "(" << p.first << "," << p.second << ")";
  return s;
}
template <class K, class V>
ostream &operator<<(ostream &s, const map<K, V> &m) {
  s << "{";
  bool f = false;
  for (const auto &it : m) {
    if (f) s << ",";
    f = true;
    s << it.first << ": " << it.second;
  }
  s << "}";
  return s;
}
template <class T, size_t N>
ostream &operator<<(ostream &s, const array<T, N> &a) {
  s << '[';
  for (int i = 0; i < (((int)(a).size())); ++i) {
    if (i) s << ',';
    s << a[i];
  }
  s << ']';
  return s;
}
vector<vector<int>> gr;
vector<int> T;
int v0;
int dfs1(int v, int pr) {
  vector<int> ts;
  for (int p : gr[v]) {
    if (p == pr) continue;
    ts.push_back(dfs1(p, v));
  }
  assert(!T[v]);
  if (!((int)(ts).size()) || (((int)(ts).size()) == 1 && ts[0] == 1))
    T[v] = 1;
  else if (((int)(ts).size()) == 2 && ts[0] == 1 && ts[1] == 1)
    T[v] = 2;
  else
    T[v] = 3;
  return T[v];
}
void dfs2(int v, int tp, int pr) {
  vector<pair<int, int>> ts(1, make_pair(tp, -1));
  for (int p : gr[v]) {
    if (p == pr) continue;
    ts.push_back(make_pair(T[p], p));
  }
  sort((ts).begin(), (ts).end());
  reverse((ts).begin(), (ts).end());
  if (ts[0].first <= 2 || ((int)(ts).size()) == 1) return;
  int c = 0;
  for (int i = 0; i < (((int)(ts).size())); ++i) {
    if (ts[i].first == 3) {
      ++c;
      if (ts[i].second != -1) {
        int tt;
        if (((int)(ts).size()) == 2 && ts[1].first == 1)
          tt = 1;
        else if (((int)(ts).size()) == 3 && ts[1].first == 1)
          tt = 2;
        else
          tt = 3;
        dfs2(ts[i].second, tt, v);
      }
    }
  }
  if (c > 2) {
    cout << "No";
    exit(0);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n < 4) {
    cout << "Yes";
    return 0;
  }
  gr.resize(n);
  T.resize(n);
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    gr[a].push_back(b);
    gr[b].push_back(a);
  }
  v0 = -1;
  for (int i = 0; i < (n); ++i) {
    assert(((int)(gr[i]).size()));
    if (((int)(gr[i]).size()) == 1) v0 = i;
  }
  assert(v0 != -1);
  dfs1(v0, -1);
  dfs2(gr[v0][0], 1, v0);
  cout << "Yes";
  return 0;
}
