#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 7;
const int mod = 1e9 + 7;
const long long INF = 9223372036854775807;
const int inf = 2e9 + 7;
vector<int> g[maxn];
int c[maxn];
int res[maxn];
int n;
vector<int> dfs(int now) {
  vector<int> res;
  for (int x : g[now]) {
    vector<int> ch = dfs(x);
    for (int v : ch) {
      res.push_back(v);
    }
  }
  if (c[now] > res.size()) {
    cout << "NO" << endl;
    exit(0);
  }
  res.insert(res.begin() + c[now], now);
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int fa;
    cin >> fa;
    cin >> c[i];
    g[fa].push_back(i);
  }
  vector<int> ans = dfs(0);
  for (int i = 0; i < (int)ans.size(); i++) {
    res[ans[i]] = i;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) {
    cout << res[i] << ' ';
  }
  cout << endl;
  return 0;
}
