#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:36777216")
using namespace std;
long long mod = 998244353;
long long inf = 1e9;
long double eps = 1e-7;
long double pi = acosl(-1);
ifstream in("input.txt");
ofstream out("output.txt");
vector<vector<int>> g;
vector<int> c;
vector<int> a;
vector<int> sub;
vector<int> used;
void dfs1(int v, int p = -1) {
  sub[v] = 0;
  for (auto to : g[v]) {
    if (to == p) continue;
    dfs1(to, v);
    sub[v] += sub[to];
  }
  if (sub[v] < c[v]) {
    cout << "NO";
    exit(0);
  }
  sub[v]++;
}
void dfs(int v, int p = -1) {
  int cc = -1;
  int pp = -1;
  for (int i = 0; i < used.size(); i++) {
    if (used[i]) {
      cc++;
      if (cc == c[v]) {
        pp = i;
        break;
      }
    }
  }
  if (pp == -1) {
    cout << "NO\n";
    exit(0);
  }
  a[v] = used[pp];
  used[pp] = 0;
  for (auto to : g[v]) {
    if (to == p) continue;
    dfs(to, v);
  }
}
int main() {
  int n;
  cin >> n;
  a.resize(n);
  int root = -1;
  used.resize(n);
  g.resize(n);
  sub.resize(n);
  for (int i = 0; i < n; i++) {
    used[i] = i + 1;
  }
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    if (x == 0) {
      if (root != -1) {
        cout << "NO";
        exit(0);
      } else {
        root = i;
      }
    } else {
      g[x - 1].push_back(i);
      g[i].push_back(x - 1);
    }
    c.push_back(y);
  }
  dfs1(root);
  dfs(root);
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
