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>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T>
inline void scan_d(T &ret) {
  char c;
  int flag = 0;
  ret = 0;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-') {
    flag = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') ret = ret * 10 + (c - '0'), c = getchar();
  if (flag) ret = -ret;
}
const int maxn = 100000 + 10;
struct Edge {
  int v, next;
} e[maxn << 1];
int head[maxn], ecnt;
int flag[maxn], ge[maxn], y[maxn], f[maxn], ans;
void add_edge(int u, int v) {
  e[ecnt].v = v;
  e[ecnt].next = head[u];
  head[u] = ecnt++;
}
int shi[maxn];
void dfs1(int u, int fa) {
  flag[u] = shi[u] = 0;
  f[u] = fa;
  int cnt = 0;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    cnt++;
  }
  ge[u] = cnt;
  if (cnt == 0) {
    flag[u] = 1;
    return;
  }
  int pp = 1, pos;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs1(v, u);
    pos = v;
    if (flag[v] != 1) pp = 0;
  }
  if (cnt == 1 && flag[pos] == 1) flag[u] = 1;
  if (cnt == 2 && pp) flag[u] = 2;
}
void dfs2(int u, int fa, int yi) {
  if (ans == -1) return;
  int ho = 0;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    if (flag[v] == 0) ho++;
  }
  y[u] = yi;
  int zhi = 0;
  if (y[u] == 2) zhi = 1;
  if (y[u] == 1)
    zhi = 1;
  else if (fa == 1 && ge[fa] <= 3) {
    vector<int> g;
    for (int i = head[fa]; ~i; i = e[i].next) {
      int v = e[i].v;
      if (v != u) g.push_back(v);
    }
    int tmp = 1;
    for (int i = 0; i < g.size(); i++)
      if (flag[g[i]] != 1) tmp = 0;
    if (tmp) zhi = 1;
  }
  if (zhi == 1) {
    if (ho > 2) ans = -1;
  } else {
    if (ho >= 2) ans = -1;
  }
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    if (y[u] == 1) {
      if (ge[u] == 1)
        dfs2(v, u, 1);
      else if (ge[u] == 2) {
        int pos;
        for (int j = head[u]; ~j; j = e[j].next) {
          int p = e[j].v;
          if (p == fa) continue;
          if (p != v) pos = p;
        }
        if (u == 1) {
          if (flag[pos] == 1)
            dfs2(v, u, 1);
          else
            dfs2(v, u, 0);
        } else {
          if (flag[pos] == 1)
            dfs2(v, u, 2);
          else
            dfs2(v, u, 0);
        }
      } else
        dfs2(v, u, 0);
    } else if (y[u] == 2 && ge[u] == 1)
      dfs2(v, u, 2);
    else
      dfs2(v, u, 0);
  }
}
int main() {
  int n, ecnt = 0;
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
  }
  dfs1(1, -1);
  ans = 0;
  dfs2(1, -1, 1);
  if (ans != -1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
