#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
vector<int> adj[N];
int c[N];
int a[N];
int subsize[N];
void calc_subsize(int u) {
  subsize[u] = 1;
  for (auto child : adj[u]) {
    calc_subsize(child);
    subsize[u] += subsize[child];
  }
}
void dfs(int u, vector<int>& elems) {
  a[u] = elems[c[u]];
  int ptr = 0;
  for (auto child : adj[u]) {
    vector<int> e;
    for (int i = 1; i <= subsize[child]; ++i) {
      if (ptr == c[u]) ptr++;
      e.push_back(elems[ptr++]);
    }
    dfs(child, e);
  }
}
void getAC() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int root = -1;
  for (int i = 1; i <= n; ++i) {
    int p;
    cin >> p >> c[i];
    if (!p) {
      root = i;
    } else {
      adj[p].push_back(i);
    }
  }
  calc_subsize(root);
  for (int i = 1; i <= n; ++i) {
    if (c[i] >= subsize[i]) {
      cout << "NO" << endl;
      return;
    }
  }
  vector<int> elems;
  for (int i = 1; i <= n; ++i) {
    elems.emplace_back(i);
  }
  dfs(root, elems);
  cout << "YES" << '\n';
  for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
  cout << '\n';
}
int main() {
  getAC();
  return 0;
}
