#include <bits/stdc++.h>
using namespace std;
vector<int> edge[2005];
int vis[2005];
int val[2005];
int ans[2005];
bool flag;
int n;
int dfscheck(int pos) {
  int nowcnt = 0;
  for (int i = 0; i < edge[pos].size(); i++) {
    nowcnt += dfscheck(edge[pos][i]);
  }
  if (val[pos] > nowcnt) flag = false;
  nowcnt++;
  return nowcnt;
}
int findans(int p) {
  int cnt = 0;
  int i;
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) cnt++;
    if (cnt == p + 1) break;
  }
  vis[i]++;
  return i;
}
void dfs(int pos) {
  ans[pos] = findans(val[pos]);
  for (int i = 0; i < edge[pos].size(); i++) {
    dfs(edge[pos][i]);
  }
  return;
}
int main() {
  int root;
  flag = true;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int tmp;
    scanf("%d%d", &tmp, &val[i]);
    edge[tmp].push_back(i);
  }
  root = edge[0][0];
  dfscheck(root);
  if (flag) {
    dfs(root);
    printf("YES\n");
    for (int i = 1; i <= n; i++) {
      printf("%d ", ans[i]);
    }
    printf("\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
