#include <bits/stdc++.h>
using namespace std;
const long long P = 998244353;
const int N = 2005;
mt19937 rng(time(0));
vector<int> g[N];
int a[N], sz[N], ans[N];
int n, x, y;
bitset<N> use, bkp[N];
void dfs(int x) {
  sz[x] = 1;
  for (auto u : g[x]) {
    dfs(u);
    sz[x] += sz[u];
  }
}
void dfs2(int x) {
  int cnt = 0;
  for (int i = (1); i <= (n); ++i) {
    cnt += use[i];
    if (cnt == a[x] + 1) {
      ans[x] = i;
      use[i] = 0;
      break;
    }
  }
  bkp[x] = use;
  use = 0;
  int now = 1, last;
  for (auto u : g[x]) {
    cnt = 0;
    last = now;
    while (cnt < sz[u]) {
      cnt += bkp[x][now];
      now++;
    }
    for (int i = (last); i <= (now); ++i) use[i] = bkp[x][i];
    dfs2(u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) {
    scanf("%d%d", &x, &y);
    g[x].push_back(i);
    a[i] = y;
  }
  dfs(g[0][0]);
  for (int i = (1); i <= (n); ++i) {
    if (a[i] >= sz[i]) {
      printf("NO");
      return 0;
    }
  }
  printf("YES\n");
  use.set();
  dfs2(g[0][0]);
  for (int i = (1); i <= (n); ++i) printf("%d ", ans[i]);
  return 0;
}
