#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long int N = 200043;
const long long int MOD = 1000000007;
long long int add(long long int x, long long int y) {
  x += y;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
long long int mul(long long int x, long long int y) {
  return (x * 1ll * y) % MOD;
}
long long int binpow(long long int x, long long int y) {
  long long int z = 1;
  while (y) {
    if (y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
long long int inv(long long int x) { return binpow(x, MOD - 2); }
long long int divide(long long int x, long long int y) {
  return mul(x, inv(y));
}
vector<long long int> v[2005];
long long int ar[2005] = {0};
long long int ans = 1;
long long int cr[2005] = {0};
long long int br[2005] = {0};
long long int n, src = 0;
long long int ctr = 0;
long long int mi = 3000;
long long int visited[2005] = {0};
void dfs(long long int c, long long int p) {
  long long int ptr = 0;
  br[c] = 1;
  for (long long int i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      ptr++;
      if (ptr == ar[c] + 1) {
        cr[c] = i, visited[i] = 1;
      }
    }
  }
  if (ar[c] > ptr - 1) ans = 0;
  for (long long int x : v[c]) {
    if (x == p) continue;
    dfs(x, c);
    br[c] += br[x];
  }
  if (br[c] - 1 < ar[c]) ans = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, i, j;
  t = 1;
  while (t--) {
    cin >> n;
    for (i = 1; i <= n; i++) {
      long long int a;
      cin >> a >> ar[i];
      if (a == 0)
        src = i;
      else
        v[a].push_back(i);
    }
    dfs(src, 0);
    if (!ans)
      cout << "NO" << endl;
    else {
      cout << "YES" << endl;
      for (i = 1; i <= n; i++) cout << cr[i] << " ";
    }
  }
}
