#include <bits/stdc++.h>
using namespace std;
int n;
int p[2005], c[2005];
vector<int> adj[2005];
int sub[2005];
int val[2005];
vector<pair<int, int> > vec;
void dfs(int x) {
  sub[x] = 1;
  for (int i = 0; i < (int)adj[x].size(); i++) {
    dfs(adj[x][i]);
    sub[x] += sub[adj[x][i]];
  }
}
void dfs2(int x) {
  for (int i = 0; i < (int)adj[x].size(); i++) {
    dfs2(adj[x][i]);
    vec.push_back(make_pair(val[adj[x][i]], adj[x][i]));
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < (int)vec.size(); i++) {
    val[vec[i].second] = i;
    vec[i].first = i;
    if (val[vec[i].second] >= c[x]) {
      val[vec[i].second]++;
      vec[i].first = val[vec[i].second];
    }
  }
  val[x] = c[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &p[i], &c[i]);
    adj[p[i]].push_back(i);
  }
  dfs(0);
  for (int i = 1; i <= n; i++) {
    if (c[i] >= sub[i]) {
      printf("NO");
      return 0;
    }
  }
  printf("YES\n");
  dfs2(0);
  for (int i = 1; i <= n; i++) {
    printf("%d ", val[i] + 1);
  }
}
