#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long mp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v[2000];
vector<int> vv[2000];
int vec[2000];
int ans[2000];
vector<int> go(int o) {
  vector<int> ret;
  for (int i : v[o]) {
    vector<int> tt = go(i);
    for (int j : tt) ret.push_back(j);
  }
  if ((int)(ret).size() < vec[o]) {
    printf("NO\n");
    exit(0);
  }
  ret.insert(ret.begin() + vec[o], o);
  return ret;
}
int main() {
  int n;
  scanf("%d", &n);
  int root;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    vec[i] = b;
    a--;
    if (a == -1)
      root = i;
    else
      v[a].push_back(i);
  }
  vector<int> ret = go(root);
  printf("YES\n");
  for (int i = 0; i < n; i++) ans[ret[i]] = i + 1;
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
}
