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;
int gcdex(int a, int b, int &x, int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int g = gcdex(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return g;
}
inline int ADD_MOD(int a, int b) { return (a + b) % 1000000007; }
inline int MUL_MOD(int a, int b) { return (int64_t(a) * b) % 1000000007; }
inline int SUB_MOD(int a, int b) { return a >= b ? a - b : a + 1000000007 - b; }
int DIV_MOD(int a, int b) {
  int x, y;
  gcdex(b, 1000000007, x, y);
  int b1 = (x % 1000000007 + 1000000007) % 1000000007;
  return MUL_MOD(a, b1);
}
inline bool EPS_EQUAL(double a, double b) { return abs(a - b) <= 0.0000001; }
inline bool EPS_LESS(double a, double b) { return b - a > 0.0000001; }
inline bool EPS_GREATER(double a, double b) { return a - b > 0.0000001; }
const int INF = numeric_limits<int>::max();
int find_first(vector<vector<int>> &graph, int node, int prevNode) {
  for (auto &i : graph[node]) {
    if (i != prevNode) {
      return find_first(graph, i, node);
    }
  }
  return node;
}
void get_node_types(vector<vector<int>> &graph, vector<int> &types, int node,
                    int prevNode) {
  int childCount = graph[node].size() - 1;
  int childTypes[3] = {0};
  for (auto &i : graph[node]) {
    if (i != prevNode) {
      get_node_types(graph, types, i, node);
      childTypes[types[i]]++;
    }
  }
  int type;
  if (childCount == 0) {
    type = 0;
  } else if (childCount == 1 && childTypes[0] == 1) {
    type = 0;
  } else if (childCount == 2 && childTypes[0] == 2) {
    type = 1;
  } else {
    type = 2;
  }
  types[node] = type;
}
bool check(vector<vector<int>> &graph, vector<int> &types, int node,
           int prevNode, bool onBranch, bool stopBranch) {
  int childTypes[3] = {0};
  for (auto &i : graph[node]) {
    if (i != prevNode) {
      childTypes[types[i]]++;
    }
  }
  if (childTypes[2] > (onBranch ? 2 : 1)) {
    return false;
  }
  if (stopBranch) {
    onBranch = false;
  } else if (onBranch) {
    int childCount = graph[node].size() - 1;
    onBranch = childCount <= 1 || (childCount == 2 && childTypes[0] == 1);
    stopBranch = (childCount == 2 && childTypes[0] == 1);
  }
  for (auto &i : graph[node]) {
    if (i != prevNode) {
      if (!check(graph, types, i, node, onBranch, stopBranch)) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(15);
  int n;
  cin >> n;
  vector<vector<int>> graph(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int first = find_first(graph, 0, 0);
  vector<int> types(n);
  get_node_types(graph, types, first, first);
  if (check(graph, types, first, first, true, false)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
