#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 2005;
int en, h[N], ans[N], n, ned[N], rt;
vector<int> q;
struct edge {
  int n, v;
} e[N];
void add(int x, int y) {
  e[++en] = (edge){h[x], y};
  h[x] = en;
}
int dfs(int x) {
  int sz = 1;
  for (int i = h[x]; i; i = e[i].n) {
    int y = e[i].v;
    sz += dfs(y);
  }
  if (sz <= ned[x]) {
    puts("NO");
    exit(0);
  }
  q.insert(q.begin() + ned[x], x);
  return sz;
}
signed main() {
  read(n);
  for (int i = 1, x; i <= n; i++) {
    read(x);
    read(ned[i]);
    if (!x)
      rt = i;
    else
      add(x, i);
  }
  dfs(rt);
  puts("YES");
  for (int i = 0; i < q.size(); i++) ans[q[i]] = i + 1;
  for (int i = 1; i <= n; i++) write(ans[i]), putchar(' ');
}
