#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long> v[2005];
queue<long long> q;
long long t[2005], c[2005], val[2005];
void solve(int root) {
  int act = 1, nod;
  while (act <= n) {
    while (!q.empty()) q.pop();
    q.push(root);
    while (1) {
      if (q.empty()) {
        cout << "NO" << '\n';
        exit(0);
      }
      nod = q.front();
      q.pop();
      if (c[nod] == 0 && val[nod] == -1) {
        val[nod] = act;
        act++;
        for (int x = t[nod]; x != 0; x = t[x]) c[x]--;
        break;
      }
      for (auto vec : v[nod]) q.push(vec);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> c[i];
    v[t[i]].push_back(i);
    val[i] = -1;
  }
  val[0] = -1;
  c[0] = 1000000000000;
  solve(0);
  cout << "YES" << '\n';
  for (int i = 1; i <= n; i++) cout << val[i] << ' ';
  return 0;
}
