#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
vector<int> v[2020];
int ans[2020], a[2020];
vector<pair<int, int>> dfs(int x, int& st) {
  vector<pair<int, int>> ret = {};
  for (auto to : v[x]) {
    auto e = dfs(to, st);
    ret.insert(ret.end(), e.begin(), e.end());
  }
  if (a[x] > ret.size()) {
    cout << "NO" << endl;
    exit(0);
  }
  vector<pair<int, int>> nr(1 + ret.size());
  for (int i = (int)(0); i < (int)(ret.size()); ++i) {
    if (i < a[x])
      nr[i] = ret[i];
    else if (i == a[x]) {
      nr[i] = {ret[i].first, x};
      ans[x] = ret[i].first;
      for (int j = (int)(i); j < (int)(ret.size()); ++j) {
        ans[ret[j].second]++;
        nr[j + 1] = {ans[ret[j].second], ret[j].second};
      }
      break;
    }
  }
  if (a[x] == ret.size()) {
    int s = nr.size();
    nr[s - 1] = {st, x};
    ans[x] = st;
  }
  st += 1;
  return nr;
}
int main() {
  int n;
  cin >> n;
  int p = -1;
  for (int i = (int)(0); i < (int)(n); ++i) {
    int x;
    cin >> x;
    if (x) {
      v[--x].push_back(i);
    } else
      p = i;
    cin >> a[i];
  }
  int st = 1;
  dfs(p, st);
  cout << "YES" << endl;
  for (int i = (int)(0); i < (int)(n); ++i) cout << ans[i] << endl;
  return 0;
}
