Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its vertices also has an integer a_i written on it. For each vertex i, Evlampiy calculated c_i — the number of vertices j in the subtree of vertex i, such that a_j < a_i. 

<image>Illustration for the second example, the first integer is a_i and the integer in parentheses is c_i

After the new year, Evlampiy could not remember what his gift was! He remembers the tree and the values of c_i, but he completely forgot which integers a_i were written on the vertices.

Help him to restore initial integers!

Input

The first line contains an integer n (1 ≤ n ≤ 2000) — the number of vertices in the tree.

The next n lines contain descriptions of vertices: the i-th line contains two integers p_i and c_i (0 ≤ p_i ≤ n; 0 ≤ c_i ≤ n-1), where p_i is the parent of vertex i or 0 if vertex i is root, and c_i is the number of vertices j in the subtree of vertex i, such that a_j < a_i.

It is guaranteed that the values of p_i describe a rooted tree with n vertices.

Output

If a solution exists, in the first line print "YES", and in the second line output n integers a_i (1 ≤ a_i ≤ {10}^{9}). If there are several solutions, output any of them. One can prove that if there is a solution, then there is also a solution in which all a_i are between 1 and 10^9.

If there are no solutions, print "NO".

Examples

Input


3
2 0
0 2
2 0


Output


YES
1 2 1 

Input


5
0 1
1 3
2 1
3 0
2 0


Output


YES
2 3 2 1 2
#include <bits/stdc++.h>
using namespace std;
struct Node {
  int32_t key;
  int32_t priority;
  Node* left;
  Node* right;
  int32_t size;
  Node(int32_t key)
      : key(key), priority(rand()), left(nullptr), right(nullptr), size(1) {}
};
int32_t get_size(Node* node) {
  if (node == nullptr) {
    return 0;
  }
  return node->size;
}
void fix_size(Node* node) {
  if (node != nullptr) {
    node->size = get_size(node->left) + get_size(node->right) + 1;
  }
}
pair<Node*, Node*> split(Node* node, int32_t left_size) {
  if (node == nullptr) {
    return {nullptr, nullptr};
  }
  if (left_size <= get_size(node->left)) {
    pair<Node*, Node*> left_splitted = split(node->left, left_size);
    node->left = left_splitted.second;
    fix_size(node);
    return {left_splitted.first, node};
  }
  pair<Node*, Node*> right_splitted =
      split(node->right, left_size - get_size(node->left) - 1);
  node->right = right_splitted.first;
  fix_size(node);
  return {node, right_splitted.second};
}
Node* merge(Node* node1, Node* node2) {
  if (node1 == nullptr) {
    return node2;
  }
  if (node2 == nullptr) {
    return node1;
  }
  if (node1->priority >= node2->priority) {
    Node* right_merged = merge(node1->right, node2);
    node1->right = right_merged;
    fix_size(node1);
    return node1;
  }
  Node* left_merged = merge(node1, node2->left);
  node2->left = left_merged;
  fix_size(node2);
  return node2;
}
Node* insert(Node* node, int32_t key, int32_t index) {
  pair<Node*, Node*> splitted = split(node, index);
  return merge(merge(splitted.first, new Node(key)), splitted.second);
}
Node* build_tree(const vector<int32_t>* child, const vector<int32_t>& costs,
                 int32_t vertex) {
  Node* curr = nullptr;
  for (int32_t curr_child : child[vertex]) {
    Node* curr_child_tree = build_tree(child, costs, curr_child);
    if (curr_child_tree == nullptr) {
      return nullptr;
    }
    curr = merge(curr, curr_child_tree);
  }
  if (get_size(curr) < costs[vertex]) {
    return nullptr;
  }
  return insert(curr, vertex, costs[vertex]);
}
void get_numbers(Node* node, int32_t& counter, vector<int32_t>& out_result) {
  if (node == nullptr) {
    return;
  }
  get_numbers(node->left, counter, out_result);
  out_result[node->key] = counter;
  counter++;
  get_numbers(node->right, counter, out_result);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int32_t count;
  cin >> count;
  vector<int32_t> child[count];
  vector<int32_t> costs(count);
  int32_t root;
  for (int32_t i = 0; i < count; i++) {
    int32_t parent, cost;
    cin >> parent >> cost;
    if (parent != 0) {
      child[parent - 1].push_back(i);
    } else {
      root = i;
    }
    costs[i] = cost;
  }
  Node* numbers_tree = build_tree(child, costs, root);
  if (numbers_tree == nullptr) {
    cout << "NO\n";
  } else {
    vector<int32_t> numbers(count);
    int32_t counter = 0;
    get_numbers(numbers_tree, counter, numbers);
    cout << "YES\n";
    for (int32_t i = 0; i < count; i++) {
      cout << numbers[i] + 1 << " ";
    }
    cout << "\n";
  }
  return 0;
}
