#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph;
vector<int> height;
vector<int> c;
int dfs(int v, int p = -1) {
  int ht = 0;
  for (auto &to : graph[v])
    if (to != p) ht = max(1 + dfs(to, v), ht);
  return height[v] = ht;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<int> p(n);
    height = c = vector<int>(n);
    graph = vector<vector<int>>(n);
    int root = -1;
    for (int i = 0; i < n; i++) {
      cin >> p[i] >> c[i];
      p[i]--;
      if (p[i] != -1) {
        graph[i].push_back(p[i]);
        graph[p[i]].push_back(i);
      } else
        root = i;
    }
    dfs(root);
    int cur = 1;
    vector<int> ans(n, -1);
    vector<bool> used(n, false);
    while (true) {
      int ht = -1;
      int v = -1;
      bool done = true;
      for (int i = 0; i < n; i++)
        if (!used[i]) done = false;
      if (done) break;
      for (int i = 0; i < n; i++) {
        if (!used[i] && c[i] == 0 && ht < height[i]) {
          ht = height[i];
          v = i;
        }
      }
      if (v == -1) {
        cout << "NO\n";
        return 0;
      }
      used[v] = true;
      ans[v] = cur;
      int u = p[v];
      while (u != -1) {
        c[u]--;
        u = p[u];
      }
      cur++;
    }
    cout << "YES\n";
    for (auto &i : ans) cout << i << " ";
    cout << endl;
  }
  return 0;
}
