#include <bits/stdc++.h>
using namespace std;
vector<int> a[2001];
double ans[2001];
int c[2001];
int un;
set<double> f(int root, int p) {
  set<double> s;
  for (int e : a[root]) {
    if (e != p) {
      for (double val : f(e, root)) s.insert(val);
    }
  }
  if (s.size() < c[root]) {
    cout << "NO";
    exit(0);
  }
  if (s.empty()) {
    ans[root] = un;
    un += 200000;
  } else if (c[root] == 0) {
    ans[root] = *s.begin() - 10000;
  } else {
    auto it = s.begin();
    while (c[root]--) ++it;
    auto itt = it;
    --itt;
    if (it == s.end())
      ans[root] = *itt + 10000;
    else
      ans[root] = (*itt + *it) / 2;
  }
  s.insert(ans[root]);
  return s;
}
int main() {
  cout << fixed << setprecision(10);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  un = 100000;
  cin >> n;
  int root;
  for (int i = 1; i < n + 1; i++) {
    int p;
    cin >> p >> c[i];
    if (p == 0)
      root = i;
    else
      a[p].push_back(i);
  }
  f(root, -1);
  pair<double, int> b[n];
  for (int i = 1; i < n + 1; i++) b[i - 1] = make_pair(ans[i], i);
  sort(b, b + n);
  int cur = 1;
  for (auto e : b) ans[e.second] = cur++;
  cout << "YES\n";
  for (int i = 1; i < n + 1; i++) cout << (int)ans[i] << ' ';
}
