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;
struct datanode {
  int a, b;
};
struct node {
  int x, a, d, b, c, cnt;
  char type;
};
static int s[200005];
static int a[200005];
static node b[200005];
void DFS1(int point, int par) {
  b[point].x = 0;
  b[point].a = 0;
  b[point].b = 0;
  b[point].c = 0;
  b[point].d = 0;
  int i;
  b[point].cnt = 0;
  for (i = s[point]; i < s[point + 1]; i++) {
    if (a[i] != par) {
      DFS1(a[i], point);
      if (b[a[i]].type == 'd')
        b[point].d++;
      else if (b[a[i]].type == 'c')
        b[point].c++;
      else if (b[a[i]].type == 'b')
        b[point].b++;
      else if (b[a[i]].type == 'a')
        b[point].a++;
      else
        b[point].x++;
      b[point].cnt++;
    }
  }
  if ((b[point].cnt <= 1) && (b[point].a == 0) && (b[point].b == 0) &&
      (b[point].d == 0) && (b[point].x == 0))
    b[point].type = 'c';
  else if ((b[point].cnt <= 2) && (b[point].a == 0) && (b[point].b == 0) &&
           (b[point].d == 0) && (b[point].x == 0))
    b[point].type = 'b';
  else if ((b[point].a == 0) && (b[point].d <= 1) && (b[point].x == 0))
    b[point].type = 'd';
  else if ((b[point].a == 0) && (b[point].d <= 2) && (b[point].x == 0))
    b[point].type = 'a';
  else
    b[point].type = 'x';
}
char res;
int N;
void DFS2(int point, int par) {
  if (b[point].type != 'x') res = 1;
  int i;
  for (i = s[point]; i < s[point + 1]; i++) {
    if (a[i] != par) {
      char parent = b[point].type;
      char child = b[a[i]].type;
      if (child == 'd')
        b[point].d--;
      else if (child == 'c')
        b[point].c--;
      else if (child == 'b')
        b[point].b--;
      else if (child == 'a')
        b[point].a--;
      else
        b[point].x--;
      b[point].cnt--;
      if ((b[point].cnt <= 1) && (b[point].a == 0) && (b[point].b == 0) &&
          (b[point].d == 0) && (b[point].x == 0))
        b[point].type = 'c';
      else if ((b[point].cnt <= 2) && (b[point].a == 0) && (b[point].b == 0) &&
               (b[point].d == 0) && (b[point].x == 0))
        b[point].type = 'b';
      else if ((b[point].a == 0) && (b[point].d <= 1) && (b[point].x == 0))
        b[point].type = 'd';
      else if ((b[point].a == 0) && (b[point].d <= 2) && (b[point].x == 0))
        b[point].type = 'a';
      else
        b[point].type = 'x';
      if (b[point].type == 'd')
        b[a[i]].d++;
      else if (b[point].type == 'c')
        b[a[i]].c++;
      else if (b[point].type == 'b')
        b[a[i]].b++;
      else if (b[point].type == 'a')
        b[a[i]].a++;
      else
        b[a[i]].x++;
      b[a[i]].cnt++;
      if ((b[a[i]].cnt <= 1) && (b[a[i]].a == 0) && (b[a[i]].b == 0) &&
          (b[a[i]].d == 0) && (b[a[i]].x == 0))
        b[a[i]].type = 'c';
      else if ((b[a[i]].cnt <= 2) && (b[a[i]].a == 0) && (b[a[i]].b == 0) &&
               (b[a[i]].d == 0) && (b[a[i]].x == 0))
        b[a[i]].type = 'b';
      else if ((b[a[i]].a == 0) && (b[a[i]].d <= 1) && (b[a[i]].x == 0))
        b[a[i]].type = 'd';
      else if ((b[a[i]].a == 0) && (b[a[i]].d <= 2) && (b[a[i]].x == 0))
        b[a[i]].type = 'a';
      else
        b[a[i]].type = 'x';
      DFS2(a[i], point);
      if (b[point].type == 'd')
        b[a[i]].d--;
      else if (b[point].type == 'c')
        b[a[i]].c--;
      else if (b[point].type == 'b')
        b[a[i]].b--;
      else if (b[point].type == 'a')
        b[a[i]].a--;
      else
        b[a[i]].x--;
      b[a[i]].cnt--;
      if (child == 'd')
        b[point].d++;
      else if (child == 'c')
        b[point].c++;
      else if (child == 'b')
        b[point].b++;
      else if (child == 'a')
        b[point].a++;
      else
        b[point].x++;
      b[point].cnt++;
      b[point].type = parent;
      b[a[i]].type = child;
    }
  }
}
int main() {
  int M;
  scanf("%d", &N);
  M = N - 1;
  static datanode data[200005];
  memset(s, 0, sizeof(s));
  int i;
  for (i = 0; i < M; i++) {
    scanf("%d %d", &(data[i].a), &(data[i].b));
    data[i].a--;
    data[i].b--;
    s[data[i].a]++;
    s[data[i].b]++;
  }
  for (i = 1; i <= N; i++) s[i] += s[i - 1];
  for (i = 0; i < M; i++) {
    s[data[i].a]--;
    a[s[data[i].a]] = data[i].b;
    s[data[i].b]--;
    a[s[data[i].b]] = data[i].a;
  }
  DFS1(0, -1);
  res = 0;
  DFS2(0, -1);
  if (res)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
