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;
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long n;
vector<long long> p, c;
vector<bool> isL;
priority_queue<double, vector<double>, greater<double> > pq[2005];
vector<bool> vis;
vector<vector<long long> > children;
vector<double> sans;
bool valid = true;
unordered_map<double, bool> taken;
void dfs(long long cur) {
  if (!valid) return;
  vis[cur] = 1;
  if (isL[cur]) return;
  for (long long i = 0; i < children[cur].size(); i++) {
    long long v = children[cur][i];
    if (v == p[cur]) continue;
    if (!vis[v]) {
      dfs(v);
      if (!valid) return;
      priority_queue<double, vector<double>, greater<double> > sub = pq[v];
      while (sub.size() > 0) {
        pq[cur].push(sub.top());
        sub.pop();
      }
    }
  }
  priority_queue<double, vector<double>, greater<double> > sub2 = pq[cur];
  double last = 0;
  for (long long i = 0; i < c[cur]; i++) {
    if (sub2.size() == 0) {
      valid = 0;
      return;
    }
    last = sub2.top();
    sub2.pop();
  }
  double next = 100000000000.0;
  if (sub2.size() > 0) next = sub2.top();
  double intermediate = (last + next) / 2;
  while (taken[intermediate]) {
    intermediate = (intermediate + last) / 2;
  }
  pq[cur].push(intermediate);
  sans[cur] = intermediate;
  taken[intermediate] = 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  p.assign(n + 1, 0);
  c.assign(n + 1, 0);
  isL.assign(n + 1, true);
  vis.assign(n + 1, false);
  vector<long long> z;
  children.assign(n + 1, z);
  sans.assign(n + 1, 0);
  long long root = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    isL[p[i]] = 0;
    if (p[i] == 0) root = i;
    children[p[i]].push_back(i);
  }
  double count = 1;
  for (long long i = 1; i <= n; i++) {
    if (isL[i]) {
      sans[i] = count++;
      pq[i].push(sans[i]);
      taken[sans[i]] = 1;
    }
  }
  dfs(root);
  for (long long i = 1; i <= n; i++) {
    if (isL[i] && c[i] != 0) {
      valid = 0;
      break;
    }
  }
  if (valid) {
    cout << "YES\n";
    vector<long long> fans(n + 1, 0);
    priority_queue<pair<double, long long>, vector<pair<double, long long> >,
                   greater<pair<double, long long> > >
        last;
    long long lcount = 1;
    for (long long i = 1; i <= n; i++) {
      last.push(make_pair(sans[i], i));
    }
    unordered_map<double, int> at;
    for (long long i = 1; i <= n; i++) {
      if (at.find(last.top().first) != at.end())
        fans[last.top().second] = at[last.top().first];
      else {
        fans[last.top().second] = lcount;
        at[last.top().first] = lcount;
        lcount++;
      }
      last.pop();
    }
    for (long long i = 1; i <= n; i++) cout << fans[i] << ' ';
    cout << endl;
  } else
    cout << "NO\n";
  return 0;
}
