#include <bits/stdc++.h>
using namespace std;
vector<long long> g[2005];
long long a[2005], s[2005], l[2005], r[2005];
void dfs(long long v) {
  long long c = 0;
  s[v] = 1;
  for (long long u = 1; u; u++) {
    c += !l[u];
    if (c > a[v]) r[v] = u, l[u] = 1, u = -1;
  }
  for (auto u : g[v]) {
    dfs(u);
    s[v] += s[u];
  }
  if (a[v] >= s[v]) {
    cout << "NO\n";
    exit(0);
  }
}
int32_t main() {
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    for (long long i = 1; i < n + 1; i++) {
      long long x;
      cin >> x >> a[i], g[x].push_back(i);
    }
    dfs(g[0][0]);
    cout << "YES\n";
    for (long long i = 1; i < n + 1; i++) cout << r[i] << " ";
    cout << "\n";
  }
  return 0;
}
