#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793238;
const long long inf = 100000000000000000;
vector<long long> v[300009];
long long c[300009], st[300009], id[300009], ans, cou;
void dfs1(long long node, long long p, long long k) {
  if (id[node] >= k) id[node]++;
  long long u, l = v[node].size();
  for (long long i = 0; i <= l - 1; i += 1) {
    u = v[node][i];
    if (u == p) continue;
    dfs1(u, node, k);
  }
}
long long dfs(long long node, long long p) {
  long long u, l = v[node].size(), mi = INT_MAX;
  for (long long i = 0; i <= l - 1; i += 1) {
    u = v[node][i];
    if (u == p) continue;
    mi = min(mi, dfs(u, node));
  }
  if (mi == INT_MAX) {
    id[node] = cou++;
    if (c[node] > 0) ans = 1;
    return id[node];
  } else {
    if (c[node] > cou - mi) {
      ans = 1;
      id[node] = cou++;
    } else {
      id[node] = INT_MAX;
      dfs1(node, -1, mi + c[node]);
      id[node] = mi + c[node];
      cou++;
    }
  }
  return mi;
}
void solve() {
  long long n, a, b, root;
  cin >> n;
  for (long long i = 1; i <= n; i += 1) {
    cin >> a >> b;
    if (a) {
      v[i].push_back(a);
      v[a].push_back(i);
    } else
      root = i;
    c[i] = b;
  }
  cou = 1;
  dfs(root, -1);
  if (ans)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (long long i = 1; i <= n; i += 1) {
      cout << id[i] << " ";
    }
  }
}
int32_t main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
