#include <bits/stdc++.h>
using namespace std;
template <typename... Args>
void input(Args &&...args) {
  (cin >> ... >> args);
}
template <typename... Args>
void print(Args &&...args) {
  (cout << ... << args) << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  vector<int> c(n);
  int root = -1;
  for (int i = 0; i < n; ++i) {
    int p;
    input(p, c[i]);
    if (p != 0)
      g[p - 1].push_back(i);
    else
      root = i;
  }
  static bool L[2000][2000];
  auto cmp = [&](int i, int j) { return L[i][j]; };
  int zz = 0;
  function<vector<int>(int, int)> dfs = [&](int cur, int prev) -> vector<int> {
    vector<int> v{cur};
    int sz = 0;
    vector<vector<int>> z;
    for (auto to : g[cur])
      if (to != prev) {
        z.emplace_back(dfs(to, cur));
        sz += z.back().size();
      }
    if (c[cur] > sz) {
      print("NO");
      exit(0);
    }
    int cnt = 0;
    for (size_t i = 0; i < z.size(); ++i)
      for (auto x1 : z[i]) {
        if (cnt < c[cur]) {
          L[x1][cur] = true;
          L[cur][x1] = false;
        } else {
          L[cur][x1] = true;
          L[x1][cur] = false;
        }
        zz += 2;
        cnt += 1;
        for (size_t j = i + 1; j < z.size(); ++j)
          for (auto x2 : z[j]) {
            L[x1][x2] = true;
            L[x2][x1] = false;
            zz += 2;
          }
      }
    for (auto &y : z) {
      if (v.size() < y.size()) swap(v, y);
      for (auto x : y) v.push_back(x);
    }
    sort(begin(v), end(v), cmp);
    return v;
  };
  auto order = dfs(root, -1);
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) ans[order[i]] = i + 1;
  print("YES");
  for (auto x : ans) cout << x << ' ';
  cout << '\n';
}
