#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 100;
int c[N] = {0}, vis[N] = {0}, ans[N] = {0}, sv[N] = {0};
set<int> s;
vector<int> g[N];
int n;
void dfscheck(int node) {
  sv[node] = 1;
  for (auto it : g[node]) {
    dfscheck(it);
    sv[node] += sv[it];
  }
}
void dfs(int node) {
  if (sv[node] <= c[node]) {
    cout << "NO\n";
    exit(0);
  }
  auto it = s.begin();
  for (int i = 0; i < c[node]; i++) it++;
  ans[node] = *it;
  s.erase(it);
  for (auto it2 : g[node]) dfs(it2);
}
int main() {
  int root = 0, i, x;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> c[i];
    if (x == 0) root = i;
    g[x].push_back(i);
  }
  for (i = 1; i <= n; i++) s.insert(i);
  dfscheck(root);
  dfs(root);
  cout << "YES\n";
  for (i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
