#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef struct {
  vector<int> child;
  vector<int> seq;
  int sz = 1;
} node;
node tree[2020];
long long v[2020], c[2020];
long long n, root;
void dfs(long long id) {
  for (int c : tree[id].child) {
    dfs(c);
    tree[id].sz += tree[c].sz;
  }
  if (c[id] >= tree[id].sz) {
    puts("NO");
    exit(0);
  }
  for (int c : tree[id].child) {
    tree[id].seq.insert(tree[id].seq.end(), tree[c].seq.begin(),
                        tree[c].seq.end());
  }
  tree[id].seq.insert(tree[id].seq.begin() + c[id], id);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long p;
    cin >> p >> c[i];
    if (p == 0)
      root = i;
    else
      tree[p - 1].child.push_back(i);
  }
  dfs(root);
  for (int i = 0; i < n; i++) {
    v[tree[root].seq[i]] = i;
  }
  puts("YES");
  for (int i = 0; i < n; i++) {
    if (i) cout << ' ';
    cout << v[i] + 1;
  }
  return 0;
}
