#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
int n;
vector<int> graph[maxn];
int c[maxn];
void fail() {
  cout << "NO\n";
  exit(0);
}
vector<int> dfs(int v) {
  vector<int> ans;
  for (auto to : graph[v]) {
    for (auto it : dfs(to)) {
      if (((int)(ans).size()) == c[v]) {
        ans.push_back(v);
      }
      ans.push_back(it);
    }
  }
  if (((int)(ans).size()) == c[v]) {
    ans.push_back(v);
  }
  if (((int)(ans).size()) < c[v]) {
    fail();
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int root = -1;
  for (int i = 1; i <= n; ++i) {
    int p;
    cin >> p >> c[i];
    if (p == 0) {
      root = i;
    } else {
      graph[p].push_back(i);
    }
  }
  vector<int> vec = dfs(root);
  vector<int> ans(n + 1);
  for (int i = 0; i < n; ++i) {
    ans[vec[i]] = i + 1;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
}
