#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2020;
const long long mod = 1000000007;
const long double eps = 1e-9;
const long long inf = ((1ll << 31ll) - 1ll);
const long long INF = (((1ll << 62ll) - 1ll) * 2ll) + 1ll;
const long double pi = acos(-1);
long long qpow(long long b, long long e) {
  if (!e) return 1;
  long long pwur = qpow(b, e >> 1);
  return (pwur * pwur) % mod * (b * (e & 1)) % mod;
}
long long p[maxn], a[maxn], root, c[maxn], subt[maxn], n;
bool mk[maxn], flag;
vector<long long> g[maxn];
void dfs(long long u, long long p) {
  subt[u] = 1;
  long long nxt = 1;
  for (long long i = 1; i <= n; i++)
    if (!mk[i]) {
      if (nxt - 1 == a[u]) {
        c[u] = i;
        mk[i] = 1;
        break;
      } else
        nxt++;
    }
  for (auto v : g[u]) {
    if (v == p) continue;
    dfs(v, u);
    subt[u] += subt[v];
  }
  if (a[u] >= subt[u]) flag = true;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(0);
  srand(time(NULL));
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> p[i] >> a[i];
    if (p[i] == 0)
      root = i;
    else
      g[p[i]].push_back(i);
  }
  dfs(root, 0);
  if (flag) {
    cout << "NO" << '\n';
    return 0;
  }
  cout << "YES" << '\n';
  for (long long i = 1; i <= n; i++) cout << c[i] << ' ';
  return 0;
}
