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;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
template <class T>
T &minn(T &a, T b) {
  if (b < a) a = b;
  return a;
}
template <class T>
T &maxx(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int &madd(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
int &msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
int &mmult(int &a, int b) { return a = (long long)a * b % 1000000007; }
int mdiv(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m, q;
vector<pair<int, int> > A[101234];
int D[101234][32];
int fnd(int i, int m, int p = -1, int k = 0) {
  if (A[i].size() == k) return 1;
  if (A[i][k].first == p) return fnd(i, m, p, k + 1);
  int &res = D[A[i][k].second][m];
  if (res >= 0) return res;
  if (((m >> 1) & 1) != ((m >> 3) & 1) && ((m >> 2) & 1))
    return res = fnd(i, m ^ (1 << 2), p, k);
  bool p0 = !((m >> 0) & 1);
  bool p1 = !((m >> 1) & 1);
  bool p2 = !((m >> 2) & 1);
  bool p3 = !((m >> 3) & 1);
  bool p4 = !((m >> 4) & 1);
  res = 0;
  int j = A[i][k].first;
  if (p0) res |= fnd(j, 31 - (1 << 0), i) && fnd(i, m + (1 << 0), p, k + 1);
  if (p4) res |= fnd(j, 31 - (1 << 4), i) && fnd(i, m + (1 << 4), p, k + 1);
  if (p0 && p1)
    res |= fnd(j, 31 - (1 << 0) - (1 << 1), i) &&
           fnd(i, m + (1 << 0) + (1 << 1), p, k + 1);
  if (p4 && p3)
    res |= fnd(j, 31 - (1 << 4) - (1 << 3), i) &&
           fnd(i, m + (1 << 4) + (1 << 3), p, k + 1);
  if (p1 && p2 && p3) {
    if (p0)
      res |= fnd(j, (1 << 4), i) &&
             fnd(i, m + (1 << 0) + (1 << 1) + (1 << 2) + (1 << 3), p, k + 1);
    if (p4)
      res |= fnd(j, (1 << 0), i) &&
             fnd(i, m + (1 << 4) + (1 << 1) + (1 << 2) + (1 << 3), p, k + 1);
    res |= fnd(j, 1 << 2, i) &&
           fnd(i, m + (1 << 1) + (1 << 2) + (1 << 3), p, k + 1);
  }
  if (p1) res |= fnd(j, (1 << 3), i) && fnd(i, m + (1 << 1), p, k + 1);
  if (p3) res |= fnd(j, (1 << 1), i) && fnd(i, m + (1 << 3), p, k + 1);
  if (p1 || p2 || p3) {
    bool b = p1 && p2 && p3;
    res |= fnd(j, (1 << 1) + (1 << 2) + (1 << 3), i) &&
           fnd(i, m ^ (b << 2), p, k + 1);
  }
  return res;
}
int main() {
  int i, j, k;
  char c;
  int a, d;
  int ts;
  for (ts = 1; scanf("%"
                     "d",
                     &(n)) > 0;
       ++ts) {
    for (i = (0); i < (n); ++i) A[i].clear();
    for (i = (0); i < (n); ++i)
      for (j = (0); j < (32); ++j) D[i][j] = -1;
    for (k = (0); k < (n - 1); ++k) {
      scanf(
          "%"
          "d",
          &(i));
      scanf(
          "%"
          "d",
          &(j));
      --i;
      --j;
      A[i].push_back(make_pair(j, k));
      A[j].push_back(make_pair(i, k));
    }
    int res = fnd(0, 0);
    printf(
        "%"
        "s",
        (res ? "Yes" : "No"));
    printf("\n"), firstout = 1;
  }
  return 0;
}
