#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
vector<int> c(N);
vector<int> g[N];
vector<int> ans(N);
vector<int> sz(N, 1);
vector<bool> used(N);
void cnt(int v) {
  used[v] = 1;
  for (auto to : g[v]) {
    if (!used[to]) {
      cnt(to);
      sz[v] += sz[to];
    }
  }
}
void dfs(int v, vector<int> lol) {
  if (sz[v] <= c[v]) {
    cout << "NO";
    exit(0);
  }
  used[v] = 1;
  ans[v] = lol[c[v]];
  vector<int> lol1;
  for (int i = 0; i < lol.size(); i++) {
    if (i == c[v])
      continue;
    else
      lol1.push_back(lol[i]);
  }
  int ind = 0;
  for (auto to : g[v]) {
    if (!used[to]) {
      vector<int> need;
      while (need.size() < sz[to]) {
        need.push_back(lol1[ind]);
        ind++;
      }
      dfs(to, need);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int r = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p >> c[i];
    if (p == 0)
      r = i;
    else {
      p--;
      g[i].push_back(p);
      g[p].push_back(i);
    }
  }
  vector<int> lol;
  for (int i = 0; i < n; i++) {
    lol.push_back(i);
  }
  cnt(r);
  fill(used.begin(), used.end(), 0);
  dfs(r, lol);
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i] + 1 << " ";
  }
  return 0;
}
