#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> d[2005];
int c[2005];
int ans[2005];
int root;
vector<int> dfs(int cv) {
  vector<int> ve;
  for (int x : d[cv]) {
    vector<int> dx = dfs(x);
    for (int y : dx) ve.push_back(y);
  }
  if (c[cv] > ve.size()) {
    cout << "NO";
    exit(0);
  }
  ve.insert(ve.begin() + c[cv], cv);
  return ve;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p >> c[i];
    if (p == 0)
      root = i;
    else
      d[p].push_back(i);
  }
  vector<int> ord = dfs(root);
  for (int i = 0; i < ord.size(); i++) ans[ord[i]] = i + 1;
  cout << "YES"
       << "\n";
  for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
  return 0;
}
