#include <bits/stdc++.h>
using namespace std;
int n, v[2001], siz[2001], ans[2001], root;
vector<vector<int>> graph;
vector<int> vals;
void dfs1(int curr, int par) {
  siz[curr] = 1;
  for (int i : graph[curr]) {
    if (i != par) {
      dfs1(i, curr);
      siz[curr] += siz[i];
    }
  }
}
void dfs2(int curr, int par) {
  if (v[curr] >= vals.size() || v[curr] >= siz[curr]) {
    cout << "NO" << endl;
    exit(0);
  }
  int p = vals[v[curr]];
  vals.erase(vals.begin() + v[curr]);
  ans[curr] = p;
  for (int i : graph[curr]) {
    if (i != par) {
      dfs2(i, curr);
    }
  }
}
int main() {
  cin >> n;
  graph.resize(n + 1);
  for (int i = 1; i <= n; i += 1) {
    vals.push_back(i);
  }
  for (int i = 1; i <= n; i += 1) {
    int a, b;
    cin >> a >> b;
    v[i] = b;
    if (a != 0) {
      graph[i].push_back(a);
      graph[a].push_back(i);
    } else {
      root = i;
    }
  }
  dfs1(root, root);
  dfs2(root, root);
  cout << "YES" << endl;
  for (int i = 1; i <= n; i += 1) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
