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:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
inline long long read() {
  long long t = 0, dp = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') dp = -1;
    c = getchar();
  }
  while (isdigit(c)) t = t * 10 + c - 48, c = getchar();
  return t * dp;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
inline void write_p(long long x) {
  write(x);
  putchar(' ');
}
const int N = 1e5 + 5;
int cnt[N][4], in[N], rt, head[N], nxt[N * 2], poi[N * 2], tcnt, n, flag = 0;
inline void add(int x, int y) {
  poi[++tcnt] = y;
  nxt[tcnt] = head[x];
  head[x] = tcnt;
  poi[++tcnt] = x;
  nxt[tcnt] = head[y];
  head[y] = tcnt;
  in[x]++;
  in[y]++;
}
inline int Dfs(int x, int fa) {
  cnt[x][0] = cnt[x][1] = cnt[x][2] = cnt[x][3] = 0;
  int t = 0;
  for (int i = head[x]; i; i = nxt[i])
    if (poi[i] != fa) {
      cnt[x][t = Dfs(poi[i], x)]++;
      if (!flag)
        if (t == 0) {
          flag = 1, rt = poi[i];
          return 3;
        }
    }
  for (int i = 2; i >= 0; --i) cnt[x][i] += cnt[x][i + 1];
  if ((flag && cnt[x][0] - cnt[x][1]) || cnt[x][1] - cnt[x][2] > 2) {
    puts("No");
    exit(0);
  }
  if (cnt[x][0] == cnt[x][3] && cnt[x][3] <= 2) {
    if (cnt[x][0] <= 1)
      return 3;
    else
      return 2;
  }
  if (cnt[x][1] - cnt[x][2] <= 1)
    return 1;
  else if (cnt[x][1] - cnt[x][2] == 2)
    return 0;
}
int main() {
  n = read();
  for (int i = 1; i <= n - 1; ++i) add(read(), read());
  for (int i = 1; i <= n - 1; ++i)
    if (in[i] > in[rt]) rt = i;
  if (in[rt] <= 2) {
    puts("Yes");
    return 0;
  }
  Dfs(rt, rt);
  if (flag) Dfs(rt, rt);
  puts("Yes");
}
