#include <bits/stdc++.h>
using namespace std;
int n, root;
vector<vector<int>> g;
vector<int> c, sz, res, used;
void calc_sz(int v) {
  for (auto ch : g[v]) {
    calc_sz(ch);
    sz[v] += sz[ch];
  }
  ++sz[v];
}
void getans(int v) {
  if (c[v] > sz[v] - 1) {
    cout << "NO" << endl;
    exit(0);
  }
  vector<int> vals;
  vals.reserve(sz[v]);
  for (int i = 1; i <= n; ++i) {
    if (!used[i] && vals.size() != sz[v]) {
      vals.push_back(i);
    }
  }
  res[v] = vals[c[v]];
  used[res[v]] = 1;
  for (auto ch : g[v]) {
    getans(ch);
  }
}
int main() {
  cin >> n;
  g.resize(n);
  c.resize(n);
  sz.resize(n);
  res.resize(n);
  used.resize(n + 1);
  for (int i = 0; i < n; ++i) {
    int pr;
    cin >> pr >> c[i];
    if (pr) {
      g[pr - 1].push_back(i);
    } else {
      root = i;
    }
  }
  calc_sz(root);
  getans(root);
  cout << "YES" << endl;
  for (auto x : res) {
    cout << x << " ";
  }
}
