#include <bits/stdc++.h>
using namespace std;
const int mx = 2e3 + 9;
void merge(vector<int>& a, vector<int>& b) {
  for (auto x : b) a.push_back(x);
}
int c[mx];
int ans[mx];
vector<int> adj[mx];
vector<int> order[mx];
void dfs(int u, int p = -1) {
  for (auto v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
    merge(order[u], order[v]);
  }
  if (c[u] > order[u].size()) {
    puts("NO");
    exit(0);
  }
  order[u].insert(order[u].begin() + c[u], u);
}
int main() {
  int n;
  scanf("%d", &n);
  int root = -1;
  for (int i = 1; i <= n; i++) {
    int p;
    scanf("%d %d", &p, &c[i]);
    if (p) {
      adj[p].push_back(i);
      adj[i].push_back(p);
    } else
      root = i;
  }
  dfs(root);
  puts("YES");
  for (int i = 0; i < n; i++) ans[order[root][i]] = i;
  for (int i = 1; i <= n; i++) printf("%d ", ans[i] + 1);
  puts("");
}
