#include <bits/stdc++.h>
const double PI = 3.141592653589793238460;
using namespace std;
vector<int> ar[2001], col;
int c[2001], vis[2001], root, sub[2001], res[2001];
int getKth(int k) {
  int res = col[k];
  for (int i = k; i + 1 < col.size(); i++) col[i] = col[i + 1];
  col.pop_back();
  return res;
}
bool dfs(int node, int par = -1) {
  if (sub[node] - 1 < c[node]) return false;
  res[node] = getKth(c[node]);
  for (int child : ar[node])
    if (child != par) {
      if (dfs(child, node) == false) return false;
    }
  return true;
}
int dfs1(int node, int par) {
  sub[node] = 1;
  for (int child : ar[node])
    if (child != par) sub[node] += dfs1(child, node);
  return sub[node];
}
int main() {
  int n, p, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    col.push_back(i);
    cin >> p >> x;
    if (p == 0)
      root = i, c[i] = x;
    else
      c[i] = x, ar[i].push_back(p), ar[p].push_back(i);
  }
  dfs1(root, -1);
  bool ans = dfs(root);
  if (ans == false)
    cout << "NO";
  else {
    cout << "YES\n";
    for (int i = 1; i <= n; i++) cout << res[i] << " ";
  }
}
