#include <bits/stdc++.h>
using namespace std;
const long long q = 239017;
const long long mod = 1e9 + 7;
const long long mod2 = 1e9 + 13;
const long long MAXN = 2e3 + 100;
const long long MAXM = 700;
const long long L = 26;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<long long> g[MAXN];
long long ct[MAXN], ans[MAXN];
void brik() {
  cout << "NO";
  exit(0);
}
long long st = 0;
void dfs(vector<long long> &a, long long v = st) {
  for (long long el : g[v]) {
    vector<long long> b;
    dfs(b, el);
    for (long long el : b) a.push_back(el);
  }
  if (ct[v] > a.size()) brik();
  a.insert(a.begin() + ct[v], v);
}
void $main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    long long p;
    cin >> p >> ct[i];
    --p;
    if (p >= 0)
      g[p].push_back(i);
    else
      st = i;
  }
  vector<long long> orda;
  dfs(orda);
  long long it = 0;
  for (long long el : orda) ans[el] = it++;
  cout << "YES" << '\n';
  for (long long i = 0; i < n; ++i) cout << ans[i] + 1 << " ";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  $main();
  return 0;
}
