#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 5;
int all = 0, star[MAXN], nxt[MAXN], ent[MAXN];
int n, A[MAXN], C[MAXN], siz[MAXN], num[MAXN], flag = 0;
void Add(int s, int e) {
  nxt[++all] = star[s];
  star[s] = all;
  ent[all] = e;
}
void Dfs(int s) {
  siz[s] = 1;
  for (int edge = star[s]; edge; edge = nxt[edge]) {
    Dfs(ent[edge]);
    siz[s] += siz[ent[edge]];
  }
}
void Cal(int s, int l, int r) {
  if (l == r) {
    num[l] = s;
    return;
  }
  int nl = l;
  for (int edge = star[s]; edge; edge = nxt[edge]) {
    Cal(ent[edge], nl, nl + siz[ent[edge]] - 1);
    nl += siz[ent[edge]];
  }
  for (int p = r; p > l + C[s]; p--) num[p] = num[p - 1];
  num[l + C[s]] = s;
}
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  int p;
  for (int i = 1; i <= n; i++) {
    cin >> p >> C[i];
    Add(p, i);
  }
  Dfs(0);
  for (int i = 1; i <= n; i++)
    if (C[i] >= siz[i]) {
      puts("NO");
      return 0;
    }
  Cal(0, 0, n);
  for (int i = 1; i <= n; i++) A[num[i]] = i;
  puts("YES");
  for (int i = 1; i <= n; i++) cout << A[i] << " ";
}
