#include <bits/stdc++.h>
using namespace std;
const int N = 10100;
const int M = 5000100;
const long long mod = 9987;
int n, rt, siz[N], head[N], cnt, c[N];
struct Node {
  int to, nex;
} edge[N * 2];
void add(int p, int q) {
  edge[cnt].to = q, edge[cnt].nex = head[p], head[p] = cnt++;
}
void dfs1(int p) {
  siz[p] = 1;
  for (int i = head[p]; ~i; i = edge[i].nex) {
    dfs1(edge[i].to);
    siz[p] += siz[edge[i].to];
  }
}
vector<int> ve;
int ans[N];
void dfs2(int p, vector<int> vc) {
  ans[p] = vc[c[p] - 1];
  int pos = 0;
  for (int i = head[p]; ~i; i = edge[i].nex) {
    int q = edge[i].to;
    vector<int> vd;
    int sum = 0;
    for (int j = pos; j < vc.size(); j++) {
      if (j == c[p] - 1) {
        pos++;
        continue;
      }
      if (++sum > siz[q]) break;
      pos++;
      vd.push_back(vc[j]);
    }
    dfs2(q, vd);
  }
}
int main() {
  memset(head, -1, sizeof(head));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p >> c[i];
    c[i]++;
    if (p != 0)
      add(p, i);
    else
      rt = i;
  }
  dfs1(rt);
  for (int i = 1; i <= n; i++) {
    if (c[i] > siz[i]) {
      printf("NO\n");
      return 0;
    }
  }
  for (int i = 0; i < n; i++) ve.push_back(i + 1);
  dfs2(rt, ve);
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
