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;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int n, a, b;
vector<int> child[100005];
vector<int> adj[100005];
bool visited[100005];
void setChild() {
  deque<int> q;
  q.push_back(1);
  visited[1] = 1;
  while (!q.empty()) {
    int t = q.front();
    q.pop_front();
    for (int i = 0; i < (int)adj[t].size(); i++) {
      int next = adj[t][i];
      if (visited[next] == 0) {
        visited[next] = t;
        child[t].push_back(next);
        q.push_back(next);
      }
    }
  }
}
bool isSimple(int idx) {
  if (child[idx].size() == 0)
    return 1;
  else if (child[idx].size() == 1)
    return isSimple(child[idx][0]);
  else
    return 0;
}
bool isPossible(int idx, int lim, int simpCnt) {
  if (child[idx].size() == 1) {
    if (simpCnt >= 2 && lim == 2) return isPossible(child[idx][0], 1, simpCnt);
    return isPossible(child[idx][0], lim, simpCnt);
  }
  int cntNotSimple = 0, cntSimple = 0;
  vector<int> nOnes;
  for (int i = 0; i < (int)child[idx].size(); i++) {
    int next = child[idx][i];
    bool simple = isSimple(next);
    if (!simple) {
      nOnes.push_back(next);
      cntNotSimple++;
    } else
      cntSimple++;
  }
  vector<bool> rmOnes(nOnes.size(), 0);
  int rmCnt = 0;
  for (int i = 0; i < (int)nOnes.size(); i++) {
    bool allSimple = 1;
    int next = nOnes[i];
    for (int j = 0; j < (int)child[next].size(); j++) {
      allSimple &= isSimple(child[next][j]);
      if (!allSimple) break;
    }
    if (child[next].size() == 2 && allSimple) {
      rmOnes[i] = 1;
      rmCnt++;
    }
  }
  if (nOnes.size() - rmCnt > lim) {
    return false;
  }
  vector<int> nOnes1;
  for (int i = 0; i < (int)nOnes.size(); i++) {
    if (rmOnes[i]) continue;
    nOnes1.push_back(nOnes[i]);
  }
  if (nOnes1.size() == 2) {
    return isPossible(nOnes1[0], 1, simpCnt) &&
           isPossible(nOnes1[1], 1, simpCnt);
  } else if (nOnes1.size() == 1) {
    if (lim == 2 && cntSimple <= 2 && nOnes.size() == 1) {
      return isPossible(nOnes1[0], 2, simpCnt + cntSimple);
    }
    return isPossible(nOnes1[0], 1, cntSimple);
  } else
    return true;
}
int main() {
  memset(visited, 0, sizeof(visited));
  scanf("%d", &n);
  for (int i = 0; i < (int)n - 1; i++) {
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  setChild();
  bool b = isPossible(1, 2, 0);
  if (b)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
