#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
const ll N = 2e3 + 5;
ll n;
vector<vi> v(N);
ll cnt[N];
ll ans[N];
ll tree[N];
ll sz[N];
void upd(ll a, ll b) {
  while (a <= n) {
    tree[a] += b;
    a += a & -a;
  }
}
ll sum(ll a) {
  ll s = 0;
  while (a > 0) {
    s += tree[a];
    a -= a & -a;
  }
  return s;
}
ll src(ll a) {
  ll l = 1, r = n, ans = -1;
  while (l <= r) {
    ll mid = (l + r) / 2;
    if (sum(mid) >= a) {
      r = mid - 1;
      ans = mid;
    } else {
      l = mid + 1;
    }
  }
  return ans;
}
void dfs(ll a, ll b) {
  ans[a] = src(cnt[a] + 1);
  upd(ans[a], -1);
  for (auto u : v[a]) {
    if (u == b) continue;
    dfs(u, a);
  }
}
void findSz(ll a, ll b) {
  sz[a] = 1;
  for (auto u : v[a]) {
    if (u == b) continue;
    findSz(u, a);
    sz[a] += sz[u];
  }
  if (sz[a] <= cnt[a]) sz[a] = (ll)1e9;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  ll root;
  for (int i = 1; i <= n; i++) {
    ll d;
    cin >> d >> cnt[i];
    if (d == 0) {
      root = i;
      continue;
    }
    v[i].push_back(d);
    v[d].push_back(i);
  }
  for (int i = 1; i <= n; i++) upd(i, 1);
  findSz(root, 0);
  if (sz[root] >= (ll)1e9) {
    cout << "NO\n";
    return 0;
  }
  dfs(root, 0);
  cout << "YES\n";
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
