#include <bits/stdc++.h>
using namespace std;
using namespace std;
int rt, n, fa[2005], c[2005], sz[2005], a[2005];
vector<int> g[2005], num;
inline void dfs1(int u) {
  int v;
  sz[u] = 1;
  for (int i = 0; i < g[u].size(); ++i) {
    v = g[u][i];
    dfs1(v);
    sz[u] += sz[v];
  }
}
inline bool dfs2(int u, const vector<int> &num) {
  int v, p = 0;
  if (c[u] >= sz[u]) return 1;
  a[u] = num[c[u]];
  vector<int> sb;
  for (int i = 0; i < g[u].size(); ++i) {
    v = g[u][i];
    sb.clear();
    while (sb.size() < sz[v]) {
      if (p != c[u]) {
        sb.push_back(num[p]);
      }
      ++p;
    }
    if (dfs2(v, sb)) return 1;
  }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", fa + i, c + i);
    if (fa[i])
      g[fa[i]].push_back(i);
    else
      rt = i;
    num.push_back(i);
  }
  dfs1(rt);
  if (dfs2(rt, num)) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 1; i <= n; ++i) {
    printf("%d ", a[i]);
  }
  puts("");
  return 0;
}
