#include <bits/stdc++.h>
using namespace std;
int num[2030], a[2030];
set<int> se;
int n, s, sc[2030];
vector<int> v[2030];
void dfs(int node) {
  num[node]++;
  for (auto pp : v[node]) {
    dfs(pp);
    num[node] += num[pp];
  }
}
void solve(int node) {
  auto it = se.begin();
  while (a[node]--) it++;
  sc[node] = *it;
  se.erase(it);
  for (auto pp : v[node]) solve(pp);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int p;
    scanf("%d%d", &p, &a[i]);
    if (p)
      v[p].push_back(i);
    else
      s = i;
  }
  dfs(s);
  for (int i = 1; i <= n; i++) {
    if (a[i] >= num[i]) {
      printf("NO\n");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) se.insert(i);
  solve(s);
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%d ", sc[i]);
  return 0;
}
