#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const int maxn = 1e6 + 5;
int n;
int a[maxn];
int P[maxn], C[maxn];
vector<int> G[maxn];
vector<int> dfs(int at) {
  vector<int> res;
  for (int to : G[at]) {
    auto rec = dfs(to);
    res.insert(res.end(), rec.begin(), rec.end());
  }
  if (C[at] > int(res.size())) {
    out("NO");
  }
  res.insert(res.begin() + C[at], at);
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> P[i] >> C[i];
    G[P[i]].push_back(i);
  }
  auto ans = dfs(G[0].front());
  for (int i = 0; i < n; i++) {
    a[ans[i]] = i + 1;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
