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 <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxn = 100000;
struct edge {
  int id, nxt;
  edge() {}
  edge(const int &_id, const int &_nxt) : id(_id), nxt(_nxt) {}
};
int st[maxn + 5], en;
edge e[(maxn << 1) + 5];
int n;
inline void add_edge(const int &first, const int &second) {
  e[en] = edge(second, st[first]), st[first] = en++;
}
inline void init() {
  memset(st, -1, sizeof st), en = 0;
  scanf("%d", &n);
  for (int i = (0), _end_ = (n - 1); i < _end_; ++i) {
    static int first, second;
    scanf("%d%d", &first, &second), --first, --second;
    add_edge(first, second);
    add_edge(second, first);
  }
}
int dp[maxn + 5], fa[maxn + 5];
int deg[maxn + 5];
bool flag = 0;
void dfs(const int &first, int limit) {
  int tot = 0;
  for (int i = st[first]; i != -1; i = e[i].nxt) {
    const int &second = e[i].id;
    if (second == fa[first]) continue;
    ++tot;
    fa[second] = first;
    dfs(second, 1);
    if ((limit -= dp[second]) < 0) flag = 1;
    dp[first] |= dp[second] || deg[second] >= 2;
  }
  deg[first] = tot;
  dp[first] |= tot > 2;
}
int main() {
  srand(time(NULL));
  init();
  while (clock() < 0.9 * CLOCKS_PER_SEC) {
    int tmp = rand() % n;
    memset(dp, 0, sizeof dp);
    fa[tmp] = -1;
    flag = 0;
    dfs(tmp, 2);
    if (!flag) {
      printf("Yes\n"), exit(0);
    }
  }
  printf("No\n");
  return 0;
}
