#include <bits/stdc++.h>
using namespace std;
int p[2010], c[2010];
vector<int> sons[2010];
int ans[2010];
vector<int> dfs(int k) {
  vector<int> v_sons;
  for (int son : sons[k]) {
    vector<int> temp = dfs(son);
    for (int i : temp) v_sons.push_back(i);
  }
  if (k == 0) return v_sons;
  if (v_sons.size() < c[k]) {
    printf("NO\n");
    exit(0);
  }
  vector<int> ret;
  for (int i = 0; i < c[k]; i++) ret.push_back(v_sons[i]);
  ret.push_back(k);
  for (int i = c[k]; i < v_sons.size(); i++) ret.push_back(v_sons[i]);
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", p + i, c + i);
    sons[p[i]].push_back(i);
  }
  vector<int> ret = dfs(0);
  for (int i = 0; i < n; i++) ans[ret[i]] = i + 1;
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
