#include <bits/stdc++.h>
const double eps = 1e-10;
const int maxn = 2000 + 10;
const long long mod = 1e9 + 7;
int sgn(double a) { return a < -eps ? -1 : a < eps ? 0 : 1; }
using namespace std;
struct edge {
  int v, nxt;
} e[maxn << 1];
int cnt;
int head[maxn];
int c[maxn], siz[maxn], p[maxn];
int vis[maxn];
int tot, n;
inline void add_edge(int u, int v) {
  e[++cnt].v = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
inline void get_siz(int u) {
  siz[u] = 1;
  for (int i = head[u]; ~i; i = e[i].nxt) {
    int v = e[i].v;
    get_siz(v);
    siz[u] += siz[v];
  }
}
inline void dfs(int u) {
  if (c[u] > siz[u] - 1) {
    cout << "NO" << endl;
    exit(0);
  }
  int xx = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) xx++;
    if (xx == c[u] + 1) {
      p[u] = i;
      vis[i] = 1;
      break;
    }
  }
  for (int i = head[u]; ~i; i = e[i].nxt) dfs(e[i].v);
}
int main() {
  scanf("%d", &n);
  int root;
  memset(head, -1, sizeof(head));
  cnt = 0;
  for (int i = 1; i <= n; i++) {
    int f;
    scanf("%d%d", &f, &c[i]);
    if (f == 0)
      root = i;
    else
      add_edge(f, i);
  }
  get_siz(root);
  tot = 1;
  dfs(root);
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%d ", p[i]);
  printf("\n");
  return 0;
}
