#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
const long long MOD = 998244353;
int p[N], c[N], ans[N];
vector<int> g[N], vc[N];
void dfs(int v) {
  if (vc[v].size() == c[v]) {
    vc[v].push_back(v);
  }
  for (auto to : g[v]) {
    dfs(to);
    for (auto tv : vc[to]) {
      vc[v].push_back(tv);
      if (vc[v].size() == c[v]) {
        vc[v].push_back(v);
      }
    }
  }
  if (vc[v].size() == c[v]) {
    vc[v].push_back(v);
  }
  if (vc[v].size() < c[v]) {
    cout << "NO" << endl;
    exit(0);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  int root = 0;
  for (int i = (1); i <= (n); ++i) {
    cin >> p[i] >> c[i];
    if (p[i] == 0) {
      root = i;
    } else {
      g[p[i]].push_back(i);
    }
  }
  dfs(root);
  cout << "YES" << endl;
  for (int i = 0; i < (vc[root].size()); ++i) {
    ans[vc[root][i]] = i + 1;
  }
  for (int i = (1); i <= (n); ++i) cout << ans[i] << " ";
  return 0;
}
