#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> v[2020], res[2020];
int c[2020];
void h(int i) {
  for (int j : v[i]) {
    h(j);
    if (res[j].size() > res[i].size()) swap(res[i], res[j]);
    for (int x : res[j]) res[i].push_back(x);
  }
  if (c[i] > res[i].size()) {
    cout << "NO\n";
    exit(0);
  }
  res[i].insert(res[i].begin() + c[i], i);
}
int ans[2020];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int r;
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p >> c[i];
    if (p) {
      p--;
      v[p].push_back(i);
    } else
      r = i;
  }
  h(r);
  int cnt = 1;
  for (int i : res[r]) {
    ans[i] = cnt++;
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) cout << ans[i] << " ";
  cout << endl;
}
