#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 100;
int n;
vector<int> adj[maxn];
int c[maxn];
int a[maxn];
int idx[maxn];
int subsz[maxn];
int cur = maxn - 50;
bool func(int u) {
  bool ret = true;
  for (auto v : adj[u]) {
    ret = ret & func(v);
  }
  subsz[u]--;
  if (subsz[u] < c[u]) ret = false;
  if (ret) {
    int st = cur + c[u];
    for (int i = cur + 1; i <= st; i++) {
      a[idx[i]] = i - 1;
      idx[i - 1] = idx[i];
    }
    idx[st] = u;
    a[u] = st;
    cur--;
  }
  return ret;
}
void calculatesubsize(int u) {
  subsz[u] = 1;
  for (auto v : adj[u]) {
    calculatesubsize(v);
    subsz[u] += subsz[v];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int p;
    scanf("%d %d", &p, &c[i]);
    adj[p].push_back(i);
  }
  calculatesubsize(adj[0][0]);
  bool ans = func(adj[0][0]);
  if (ans) {
    printf("YES\n");
    for (int i = 1; i <= n; i++) {
      printf("%d ", a[i]);
    }
    printf("\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
