#include <bits/stdc++.h>
using namespace std;
double _eps = 1e-6;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<int> adj[2000 + 100];
int arr[2000 + 100];
int f = 1;
void dfs(int root, vector<int> &v) {
  vector<int> nv;
  for (int x : adj[root]) {
    dfs(x, nv);
  }
  if (arr[root] <= nv.size()) {
    nv.insert(nv.begin() + arr[root], root);
  } else
    f = 0;
  for (int x : nv) v.push_back(x);
}
int main() {
  int n;
  cin >> n;
  int root;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> arr[i];
    if (a == 0)
      root = i;
    else {
      adj[a].push_back(i);
    }
  }
  vector<int> v;
  dfs(root, v);
  if (!f)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 1, k = 0; i <= n; ++i, k++) {
      arr[v[k]] = i;
    }
    for (int i = 1; i <= n; ++i) {
      cout << arr[i] << " ";
    }
    puts("");
  }
  return 0;
}
