#include <bits/stdc++.h>
using namespace std;
const int N = 2100;
int n, fa[N], s[N], root, size[N], ans[N];
vector<int> to[N], a[N];
template <class T>
inline void read(T &x) {
  x = 0;
  char ch = getchar(), w = 0;
  while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = w ? -x : x;
  return;
}
void dfs1(int now) {
  size[now] = 1;
  if (!s[now]) a[now].push_back(now);
  for (auto &v : to[now]) {
    dfs1(v), size[now] += size[v];
    for (auto &k : a[v]) {
      a[now].push_back(k);
      if (a[now].size() == s[now]) a[now].push_back(now);
    }
  }
  if (size[now] <= s[now]) {
    printf("NO\n");
    exit(0);
  }
  return;
}
int main() {
  read(n);
  for (register int i = 1; i <= n; ++i) {
    read(fa[i]), read(s[i]);
    if (fa[i])
      to[fa[i]].push_back(i);
    else
      root = i;
  }
  dfs1(root);
  printf("YES\n");
  for (register int i = 0; i < n; ++i) ans[a[root][i]] = i + 1;
  for (register int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  return 0;
}
