#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[2001];
vector<pair<long long, long long> > ans;
long long p[2001], c[2001];
long long power(long long a, long long m, long long mod) {
  long long ans = 1;
  while (m) {
    if (m % 2) {
      ans *= a;
      ans %= (mod);
    }
    a = (a * a) % (mod);
    m >>= 1;
  }
  return ans;
}
void init(long long* a, long long n, long long val) {
  for (long long i = 0; i < n; i++) a[i] = val;
}
long long tmk = 1;
long long b = 1;
void dfs(long long i) {
  long long j;
  long long t = tmk;
  for (j = 0; j < adj[i].size(); j++) {
    tmk++;
    dfs(adj[i][j]);
  }
  if (!b) return;
  t = tmk - t;
  if (t < c[i]) {
    b = 0;
    return;
  }
  vector<long long> tmp;
  for (j = (long long)ans.size() - 1; j > (long long)ans.size() - 1 - t; j--) {
    tmp.push_back(ans[j].first);
  }
  sort(tmp.begin(), tmp.end());
  long long k;
  if (c[i])
    k = tmp[c[i] - 1] + 1;
  else
    k = 1;
  if (i) {
    for (j = 0; j < ans.size(); j++) {
      if (ans[j].first >= k) {
        ans[j].first++;
      }
    }
    ans.push_back(make_pair(k, i));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1, i, j;
  long long n;
  cin >> n;
  long long x, y;
  long long r;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    p[i + 1] = x;
    adj[x].push_back(i + 1);
    c[i + 1] = y;
  }
  c[0] = 0;
  p[0] = 0;
  dfs(0);
  if (!b) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (i = 0; i < ans.size(); i++) {
    c[ans[i].second] = ans[i].first;
  }
  for (i = 1; i < n + 1; i++) {
    cout << c[i] << " ";
  }
  cout << endl;
  return 0;
}
