#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
struct Edge {
  int num;
  int next;
} edge[N];
int num[N];
bool used[N];
int tot, last[N];
int ans[N];
void Add(int i, int j) {
  tot++;
  edge[tot].num = j;
  edge[tot].next = last[i];
  last[i] = tot;
}
int cnt[N], flag = 1;
void dfs(int u) {
  for (int k = last[u]; k != 0; k = edge[k].next) {
    int v = edge[k].num;
    dfs(v);
    cnt[u] += cnt[v];
  }
  if (num[u] > cnt[u]) {
    flag = 0;
    return;
  }
  cnt[u]++;
}
void dfs1(int u, int l, int r) {
  int total = 0;
  for (int i = l; i <= r; i++) {
    if (used[i] == 0 && total == num[u]) {
      ans[u] = i;
      used[i] = 1;
      break;
    }
    if (used[i] == 0) total++;
  }
  int left = l - 1;
  for (int k = last[u]; k != 0; k = edge[k].next) {
    int v = edge[k].num;
    total = 0;
    for (int j = left + 1; j <= r; j++)
      if (used[j] == 0) {
        total++;
        if (total == cnt[v]) {
          dfs1(v, l, j);
          left = j;
          break;
        }
      }
  }
}
int main() {
  int n, root;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a != 0)
      Add(a, i);
    else
      root = i;
    num[i] = b;
  }
  dfs(root);
  if (flag == 0) {
    printf("NO");
    return 0;
  }
  dfs1(root, 1, n);
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
