#include <bits/stdc++.h>
using namespace std;
vector<int> g[2005];
int c[2005];
vector<int> v;
int subtree[2005];
int ans[2005];
int dfs(int index) {
  subtree[index] = 1;
  if (c[index] < v.size()) {
    ans[index] = v[c[index]];
  } else {
    cout << "NO\n";
    exit(0);
  }
  v.erase(v.begin() + c[index]);
  for (auto it = g[index].begin(); it != g[index].end(); it++) {
    int temp = dfs(*it);
    if (temp != INT_MIN) subtree[index] += temp;
  }
  if (subtree[index] - 1 < c[index]) {
    cout << "NO\n";
    exit(0);
  }
  return subtree[index];
}
int main() {
  int n, parent, b, root;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> parent >> b;
    if (parent == 0) {
      root = i;
    } else {
      g[parent].push_back(i);
    }
    c[i] = b;
    v.push_back(i);
  }
  int check = dfs(root);
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
