#include <bits/stdc++.h>
using namespace std;
int n, fa[2005], c[2005], siz[2005], id[2005], dfn[2005], tot;
vector<int> G[2005];
int vis[2005];
int tmp[2005], cnt = 0;
void dfs(int x) {
  siz[x] = 1;
  dfn[x] = ++tot;
  for (int i = 0; i < G[x].size(); i++) {
    int V = G[x][i];
    dfs(V);
    siz[x] += siz[V];
  }
  cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (dfn[x] < dfn[i] && dfn[i] <= dfn[x] + siz[x] - 1) tmp[++cnt] = id[i];
  }
  sort(tmp + 1, tmp + cnt + 1);
  id[x] = tmp[c[x]] + 1;
  for (int i = 1; i <= n; i++) {
    if (i == x) continue;
    if (id[i] >= id[x]) id[i]++;
  }
}
int root;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &fa[i], &c[i]);
    if (fa[i] == 0)
      root = i;
    else
      G[fa[i]].push_back(i);
  }
  dfs(root);
  for (int i = 1; i <= n; i++) {
    if (c[i] >= siz[i]) {
      printf("NO");
      return 0;
    }
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++) {
    printf("%d ", id[i]);
  }
  return 0;
}
