#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int w = 1, c = 0;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') w = -1;
  for (; isdigit(ch); ch = getchar()) c = (c << 1) + (c << 3) + (ch ^ 48);
  return w * c;
}
const int M = 2020;
vector<int> v[M];
int res[M][M], c[M], tt[M], ans[M], sz[M];
bool dfs(int x) {
  sz[x] = 1;
  for (int i = (0); i <= (((int)v[x].size() - 1)); ++i) {
    int y = v[x][i];
    if (!dfs(y)) return 0;
    sz[x] += sz[y];
  }
  if (c[x] >= sz[x]) return 0;
  for (int i = (0); i <= (((int)v[x].size() - 1)); ++i) {
    int y = v[x][i];
    for (int j = (1); j <= (tt[y]); ++j) {
      ++tt[x];
      if (tt[x] - 1 == c[x]) {
        res[x][tt[x]] = x;
        tt[x]++;
      }
      res[x][tt[x]] = res[y][j];
    }
  }
  if (c[x] == sz[x] - 1) res[x][++tt[x]] = x;
  return 1;
}
int n, p[M], rt;
int main() {
  n = read();
  for (int i = (1); i <= (n); ++i) {
    p[i] = read();
    c[i] = read();
    if (p[i])
      v[p[i]].push_back(i);
    else
      rt = i;
  }
  if (dfs(rt)) {
    puts("YES");
    for (int i = (1); i <= (n); ++i) {
      ans[res[rt][i]] = i;
    }
    for (int i = (1); i <= (n); ++i) cout << ans[i] << " ";
  } else
    puts("NO");
  return 0;
}
