#include <bits/stdc++.h>
using namespace std;
int t, n, p[2005], c[2005], ans[2005], sum[2005];
vector<int> v[2005];
bool b[2005];
void pre(int first) {
  sum[first] = 1;
  for (int i = 0; i < v[first].size(); i++) {
    pre(v[first][i]);
    sum[first] += sum[v[first][i]];
  }
  return;
}
void f(int first, int l, int r) {
  if (sum[first] - 1 < c[first]) {
    printf("NO\n");
    exit(0);
  }
  int ct = c[first];
  for (int i = l; i <= r; i++) {
    if (!ct && !b[i]) {
      ct = i;
      break;
    }
    if (!b[i]) ct--;
  }
  ans[first] = ct;
  b[ct] = true;
  for (int i = 0; i < v[first].size(); i++) {
    f(v[first][i], 1, n);
  }
  return;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    v[p[i]].push_back(i);
  }
  int start = v[0][0];
  pre(start);
  f(start, 1, n);
  printf("YES\n");
  for (int i = 1; i <= n; i++) {
    printf(i == n ? "%d\n" : "%d ", ans[i]);
  }
  return 0;
}
