#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 2010;
const int mod = 1e9 + 7;
vector<int> xiao[N];
int arr[N], ans[N], vis[N], n, flag;
int dfs(int rt) {
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      sum++;
      if (sum == arr[rt] + 1) {
        ans[rt] = i;
        vis[i] = 1;
        break;
      }
    }
  }
  int num = 0;
  for (int i = 0; i < xiao[rt].size(); i++) num += dfs(xiao[rt][i]);
  if (num < arr[rt]) flag = 1;
  return num + 1;
}
int main() {
  int rt;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int fa;
    scanf("%d%d", &fa, &arr[i]);
    if (fa == 0)
      rt = i;
    else
      xiao[fa].push_back(i);
  }
  dfs(rt);
  if (flag)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
