#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> v, c, ans, subtree;
int k;
void dfs2(int u, int p) {
  subtree[u] = 1;
  for (int to : g[u]) {
    if (to == p) {
      continue;
    }
    dfs2(to, u);
    subtree[u] += subtree[to];
  }
}
void dfs(int u, int p) {
  ans[u] = v[c[u]];
  v.erase(v.begin() + c[u]);
  for (int to : g[u]) {
    if (to == p) {
      continue;
    }
    dfs(to, u);
  }
}
int main() {
  k = 1;
  int n;
  cin >> n;
  c = vector<int>(n + 2);
  ans = vector<int>(n + 2);
  subtree = vector<int>(n + 2);
  g = vector<vector<int> >(n + 2);
  int root;
  for (int i = 1; i <= n; i++) {
    v.push_back(i);
    int p;
    cin >> p >> c[i];
    if (p == 0) {
      root = i;
    } else {
      g[i].push_back(p);
      g[p].push_back(i);
    }
  }
  dfs2(root, 0);
  for (int i = 1; i <= n; i++) {
    if (c[i] >= subtree[i]) {
      k = 0;
    }
  }
  if (k == 0) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  dfs(root, 0);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
  return 0;
}
