#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > children;
vector<int> c, a;
bool possible = true;
int nextVal = 1;
void changeVals(int node, int barrier) {
  if (a[node] >= barrier) ++a[node];
  for (int child : children[node]) changeVals(child, barrier);
}
void findVals(int node, vector<int> &x) {
  x.push_back(a[node]);
  for (int child : children[node]) findVals(child, x);
}
void dfs(int node) {
  vector<int> subtree;
  for (int child : children[node]) {
    dfs(child);
    if (!possible) return;
    findVals(child, subtree);
  }
  sort(subtree.begin(), subtree.end());
  if (c[node] > subtree.size()) {
    possible = false;
    return;
  }
  if (c[node] == subtree.size())
    a[node] = nextVal;
  else {
    a[node] = subtree[c[node]];
    for (int child : children[node]) changeVals(child, a[node]);
  }
  ++nextVal;
}
int main() {
  int n;
  cin >> n;
  children.resize(1 + n), c.resize(1 + n), a.resize(1 + n);
  for (int i = 1; i <= n; ++i) {
    int pi;
    cin >> pi >> c[i];
    children[pi].push_back(i);
  }
  dfs(children[0][0]);
  if (possible) {
    cout << "YES" << endl;
    for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
    cout << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
