#include <bits/stdc++.h>
using namespace std;
const long long NN = 2e3 + 5;
long long n, i, p[NN], a[NN], jaw[NN], R, ketemu;
vector<long long> v[NN];
void dfs(long long pos) {
  if (ketemu) return;
  if (a[pos] == 0) {
    ketemu = pos;
    return;
  }
  for (long long i = 0; i < v[pos].size(); i++) dfs(v[pos][i]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long ta, tb;
    cin >> p[i] >> a[i];
    if (p[i] == 0)
      R = i;
    else
      v[p[i]].push_back(i);
  }
  for (long long i = 1; i <= n; i++) {
    ketemu = 0;
    dfs(R);
    if (ketemu == 0) {
      cout << "NO\n";
      return 0;
    }
    jaw[ketemu] = i;
    while (ketemu) {
      a[ketemu]--;
      ketemu = p[ketemu];
    }
  }
  cout << "YES\n";
  for (long long i = 1; i <= n; i++) cout << jaw[i] << " ";
  cout << "\n";
}
