#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;
inline int read() {
  char c = getchar();
  int t = 0, f = 1;
  while ((!isdigit(c)) && (c != EOF)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ((isdigit(c)) && (c != EOF)) {
    t = (t << 3) + (t << 1) + (c ^ 48);
    c = getchar();
  }
  return t * f;
}
int n, p[maxn];
struct edge {
  int v, p;
} e[maxn << 1];
int h[maxn], cnt;
inline void add(int a, int b) {
  e[++cnt].p = h[a];
  e[cnt].v = b;
  h[a] = cnt;
}
int rt, pos;
struct node {
  int l, r, rd, val, sz;
} t[maxn];
int tot;
inline int newnode(int x) {
  t[++tot].val = x;
  t[tot].rd = rand();
  t[tot].sz = 1;
  return tot;
}
inline void pushup(int rt) { t[rt].sz = t[t[rt].l].sz + t[t[rt].r].sz + 1; }
inline void split(int rt, int &l, int &r, int k) {
  if (!rt) {
    l = r = 0;
    return;
  }
  if (t[t[rt].l].sz + 1 >= k) {
    r = rt;
    split(t[rt].l, l, t[rt].l, k);
  } else {
    l = rt;
    split(t[rt].r, t[rt].r, r, k - t[t[rt].l].sz - 1);
  }
  pushup(rt);
}
inline int merge(int x, int y) {
  if ((!x) || (!y)) return x ^ y;
  if (t[x].rd < t[y].rd) {
    t[x].r = merge(t[x].r, y);
    pushup(x);
    return x;
  } else {
    t[y].l = merge(x, t[y].l);
    pushup(y);
    return y;
  }
}
int p1, p2, p3, p4;
inline void insert(int p, int val) {
  split(rt, p1, p2, p);
  rt = merge(p1, merge(newnode(val), p2));
}
int flag, sz[maxn];
void dfs(int u) {
  sz[u] = 1;
  for (int i = h[u]; i; i = e[i].p) {
    int v = e[i].v;
    dfs(v);
    sz[u] += sz[v];
    if (flag == -1) return;
  }
  if (sz[u] <= p[u]) {
    flag = -1;
    return;
  }
  insert(p[u] + 1, u);
}
int tim = 0, ans[maxn];
void dfs2(int rt) {
  if (t[rt].l) dfs2(t[rt].l);
  ans[t[rt].val] = ++tim;
  if (t[rt].r) dfs2(t[rt].r);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    int x = read();
    if (x == 0)
      pos = i;
    else
      add(x, i);
    p[i] = read();
  }
  dfs(pos);
  dfs2(rt);
  if (flag == -1) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
