#include <bits/stdc++.h>
using namespace std;
const int N = 2100;
int n, root, c[N], a[N], cnt[N];
vector<int> adj[N];
void Dfs1(int u, int p) {
  cnt[u] = 1;
  for (int v : adj[u])
    if (v != p) {
      Dfs1(v, u);
      cnt[u] += cnt[v];
    }
}
void Dfs2(int u, int p, vector<int> num) {
  if (c[u] >= cnt[u]) {
    cout << "NO";
    exit(0);
  }
  a[u] = num[c[u]];
  num[c[u]] = 0;
  for (int v : adj[u])
    if (v != p) {
      vector<int> tmp;
      for (int i = 1; i <= cnt[v]; i++) {
        if (num.back() == 0) {
          num.pop_back();
          i--;
        } else {
          tmp.push_back(num.back());
          num.pop_back();
        }
      }
      reverse(tmp.begin(), tmp.end());
      Dfs2(v, u, tmp);
    }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p >> c[i];
    if (p == 0)
      root = i;
    else {
      adj[i].push_back(p);
      adj[p].push_back(i);
    }
  }
  vector<int> tmp;
  for (int i = 1; i <= n; i++) tmp.push_back(i);
  Dfs1(root, root);
  Dfs2(root, root, tmp);
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) cout << a[i] << ' ';
}
