#include <bits/stdc++.h>
using namespace std;
struct Node {
  vector<long long int> ch;
  long long int c, val;
  Node() { c = 0; }
};
long long int solve(Node t[], long long int cur, long long int& ans) {
  long long int sum = 0;
  for (auto it : t[cur].ch) sum += solve(t, it, ans);
  if (sum < t[cur].c) ans = 0;
  return sum + 1;
}
void solve2(Node t[], long long int cur, set<long long int>& s) {
  long long int n = t[cur].c, l = 1, r = 1e+8;
  while (l < r) {
    long long int m = (l + r + 1) / 2;
    if (distance(s.begin(), s.lower_bound(m)) > n)
      r = m - 1;
    else
      l = m;
  }
  t[cur].val = l;
  s.erase(l);
  for (auto it : t[cur].ch) solve2(t, it, s);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, p, c, ans = 1;
  cin >> n;
  Node t[n + 1];
  for (long long int i = 1; i <= n; i++) {
    cin >> p >> c;
    t[p].ch.push_back(i);
    t[i].c = c;
  }
  solve(t, 0, ans);
  if (ans) {
    set<long long int> s;
    for (long long int i = 1; i <= n; i++) s.insert(i);
    solve2(t, t[0].ch[0], s);
    printf("YES\n");
    for (long long int i = 1; i <= n; i++) printf("%lld ", t[i].val);
  } else
    printf("NO");
  return 0;
}
