#include <bits/stdc++.h>
using namespace std;
int root, n, val[2010], res[2010];
int f;
vector<int> edge[2010];
queue<int> dfs(int now) {
  queue<int> temp;
  for (auto to : edge[now]) {
    queue<int> buf = dfs(to);
    while (!buf.empty()) {
      temp.push(buf.front());
      buf.pop();
    }
  }
  int sz = temp.size();
  if (val[now] > sz) f = 1;
  if (val[now] == 0) temp.push(now);
  for (int i = 1; i <= sz; i++) {
    temp.push(temp.front());
    temp.pop();
    if (val[now] == i) temp.push(now);
  }
  return temp;
}
int main() {
  cin >> n;
  for (int i = 1, fa; i <= n; i++) {
    cin >> fa >> val[i];
    if (fa != 0)
      edge[fa].push_back(i);
    else
      root = i;
  }
  queue<int> que = dfs(root);
  int cnt = 0;
  while (!que.empty()) {
    res[que.front()] = ++cnt;
    que.pop();
  }
  if (f) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) cout << res[i] << " ";
  return 0;
}
