#include <bits/stdc++.h>
using namespace std;
vector<int> adj[2005], c(2005);
vector<int> dfs(int node) {
  vector<int> use;
  for (auto& it : adj[node]) {
    vector<int> t1 = dfs(it);
    use.insert(use.begin(), t1.begin(), t1.end());
  }
  if (c[node] > use.size()) {
    cout << "NO\n";
    exit(0);
  }
  use.insert(use.begin() + c[node], node);
  return use;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, root;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int r1, r2;
    cin >> r1 >> r2;
    if (r1 == 0) {
      root = i;
    } else {
      adj[r1].push_back(i);
    }
    c[i] = r2;
  }
  vector<int> use = dfs(root);
  vector<int> ans(n + 5);
  for (int i = 0; i < n; ++i) {
    ans[use[i]] = i + 1;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
  return 0;
}
