#include <bits/stdc++.h>
using namespace std;
const long long int M = 2e3 + 1;
vector<vector<long long int> > g(M);
long long int root, mx, timer;
vector<long long int> c(M), ans(M), vt(M), lt(M);
long long int n;
bool fl = true;
void dfs(long long int u) {
  if (!fl) return;
  vt[u] = (++timer);
  for (auto x : g[u]) {
    dfs(x);
  }
  lt[u] = timer;
  vector<long long int> v;
  for (long long int i = 1; i <= n; i++) {
    if (vt[i] > vt[u] && vt[i] <= lt[u]) {
      v.push_back(ans[i]);
    }
  }
  if ((long long int)v.size() < c[u]) {
    fl = false;
    return;
  }
  if ((long long int)v.size() == c[u]) {
    ans[u] = (++mx);
  } else {
    sort(v.begin(), v.end());
    ans[u] = v[c[u]];
    for (long long int i = 1; i <= n; i++) {
      if (ans[i] >= ans[u] && i != u) {
        ans[i]++;
      }
      mx = max(mx, ans[i]);
    }
  }
}
void solve() {
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    long long int p;
    cin >> p >> c[i];
    if (!p)
      root = i;
    else
      g[p].push_back(i);
  }
  mx = 0;
  dfs(root);
  if (!fl) {
    cout << "NO" << '\n';
    return;
  }
  cout << "YES" << '\n';
  for (long long int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc;
  tc = 1;
  for (int i = 1; i <= tc; i++) {
    solve();
  }
  return 0;
}
