#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &k) {
  k = 0;
  int flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    k = k * 10 + c - '0';
    c = getchar();
  }
  k *= flag;
}
const int N = 2005;
struct node {
  int y, next;
} b[N];
int n, m, k, s, t, head[N], tot, size[N];
int a[N], bb[N], ans[N], root;
void dfs(int x) {
  int o = 0;
  for (int i = 1; i <= n; ++i) {
    if (bb[i] == 0) ++o;
    if (o == a[x] + 1) {
      ans[x] = i;
      bb[i] = 1;
      break;
    }
  }
  size[x] = 1;
  for (int k = head[x]; k; k = b[k].next) {
    int y = b[k].y;
    dfs(y);
    size[x] += size[y];
  }
}
void add(int s, int t) {
  b[++tot].y = t;
  b[tot].next = head[s];
  head[s] = tot;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    read(s);
    read(a[i]);
    if (s)
      add(s, i);
    else
      root = i;
  }
  dfs(root);
  for (int i = 1; i <= n; ++i)
    if (size[i] <= a[i]) {
      cout << "NO";
      return 0;
    }
  cout << "YES" << endl;
  for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
}
