#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
struct node {
  int v;
  int son;
  bool isleaf;
} tree[N * 4];
void build(int index, int l, int r) {
  tree[index].son = r - l + 1;
  if (l == r) {
    tree[index].v = l;
    tree[index].isleaf = 1;
    return;
  }
  build(index * 2, l, (l + r) / 2);
  build(index * 2 + 1, (l + r) / 2 + 1, r);
}
int findk(int index, int k) {
  if (tree[index].isleaf) {
    tree[index].son = 0;
    return tree[index].v;
  }
  tree[index].son--;
  if (tree[index * 2].son >= k) {
    return findk(index * 2, k);
  } else {
    return findk(index * 2 + 1, k - tree[index * 2].son);
  }
}
int n;
vector<int> son[N];
int ct[N];
int root;
int ans[N];
bool ext = 1;
int ctson[N];
void dfs1(int v) {
  int len = son[v].size();
  if (len == 0) {
    ctson[v] = 1;
    if (ct[v] > 0) {
      ext = 0;
    }
    return;
  }
  ctson[v] = 1;
  for (int i = 0; i < len; i++) {
    dfs1(son[v][i]);
    ctson[v] += ctson[son[v][i]];
  }
  if (ct[v] > ctson[v] - 1) {
    ext = 0;
  }
  return;
}
void dfs2(int v) {
  int len = son[v].size();
  ans[v] = findk(1, ct[v] + 1);
  for (int i = 0; i < len; i++) {
    dfs2(son[v][i]);
  }
}
int main() {
  scanf("%d", &n);
  build(1, 1, n);
  int p, c;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &p, &c);
    son[p].push_back(i);
    ct[i] = c;
    if (p == 0) {
      root = i;
    }
  }
  dfs1(root);
  if (!ext) {
    puts("NO");
    return 0;
  }
  dfs2(root);
  puts("YES");
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
