#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int p[2005], c[2005], val[2005], t[2005];
vector<int> ch[2005];
vector<int> ord[2005];
void dfs(int v) {
  for (auto& x : ch[v]) {
    dfs(x);
    for (auto& y : ord[x]) {
      ord[v].push_back(y);
    }
  }
  if (ord[v].size() < c[v]) {
    cout << "NO";
    exit(0);
  }
  ord[v].insert(ord[v].begin() + c[v], v);
}
int ans[2005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    ch[p[i]].push_back(i);
  }
  dfs(0);
  for (int i = 1; i <= n; i++) ans[ord[0][i]] = i;
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
}
