#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast", "-funroll-all-loops")
using namespace std;
const long long N = 2e3 + 10;
long long n, res[N], p[N], c[N], rt, sz[N], vis[N];
long long head[N], nex[N], to[N], tot;
inline void add(long long a, long long b) {
  to[++tot] = b;
  nex[tot] = head[a];
  head[a] = tot;
}
void dfs_sz(long long x) {
  sz[x] = 1;
  for (long long i = head[x]; i; i = nex[i]) {
    dfs_sz(to[i]);
    sz[x] += sz[to[i]];
  }
}
void dfs(long long x) {
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) cnt++;
    if (cnt == c[x] + 1) {
      res[x] = i;
      break;
    }
  }
  vis[res[x]] = 1;
  for (long long i = head[x]; i; i = nex[i]) dfs(to[i]);
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    if (!p[i]) rt = i;
    if (p[i]) add(p[i], i);
  }
  dfs_sz(rt);
  for (long long i = 1; i <= n; i++)
    if (c[i] >= sz[i]) return puts("NO"), 0;
  dfs(rt);
  puts("YES");
  for (long long i = 1; i <= n; i++) cout << res[i] << ' ';
  puts("");
  return 0;
}
