#include <bits/stdc++.h>
using namespace std;
const int N = 3e3;
int p[N], c[N];
vector<int> g[N];
bool FAIL = false;
inline int max(int a, int b) { return a > b ? a : b; }
vector<int> f(int v, int pr = -1) {
  vector<int> res, w;
  bool done = false;
  for (int u : g[v]) {
    if (u == pr) continue;
    w = f(u, v);
    if (w.size() <= c[v] || done) {
      if (!done) c[v] -= w.size();
      for (int x : w) res.push_back(x);
      continue;
    }
    done = true;
    for (int i = 0; i < c[v]; ++i) res.push_back(w[i]);
    res.push_back(v);
    for (int i = c[v]; i < w.size(); ++i) res.push_back(w[i]);
    c[v] = 0;
  }
  if (!done) res.push_back(v);
  if (c[v]) FAIL = true;
  return res;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> p[i] >> c[i], --p[i];
    if (p[i] + 1) g[i].push_back(p[i]), g[p[i]].push_back(i);
  }
  int root;
  for (int i = 0; i < n; ++i)
    if (p[i] == -1) root = i;
  vector<int> a = f(root, -1);
  if (FAIL) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  int num[n];
  for (int i = 0; i < a.size(); ++i) num[a[i]] = i + 1;
  for (int i = 0; i < n; ++i) cout << num[i] << ' ';
  return 0;
}
