#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
vector<long long int> g[2002], c(2002), res(2002);
vector<long double> f(2002);
set<long double> st;
long long int n;
vector<long long int> dfs(long long int x) {
  vector<vector<long long int>> cum;
  vector<long long int> lst;
  long long int i = 0, val = 0, sum = 0, flag = 1;
  for (auto it : g[x]) {
    cum.push_back(dfs(it));
  }
  for (i = 0; i < cum.size(); i++) {
    for (long long int j = 0; j < cum[i].size(); j++) {
      if (val == c[x]) {
        sum++;
        lst.push_back(x);
        flag = 0;
      }
      val++;
      lst.push_back(cum[i][j]);
      res[cum[i][j]] += sum;
    }
    sum += cum[i].size();
  }
  res[x] = c[x] + 1;
  if (flag) lst.push_back(x);
  return lst;
}
long long int check(long long int x) {
  long long int sz = 0;
  for (auto it : g[x]) {
    sz += check(it);
  }
  if (sz < c[x]) {
    cout << "NO"
         << "\n";
    exit(0);
  }
  return sz + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin.tie(NULL);
  long long int m, i, j, k, ans = 0, p, root;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> p >> c[i];
    if (p == 0)
      root = i;
    else {
      p--;
      g[p].push_back(i);
    }
  }
  check(root);
  dfs(root);
  cout << "YES"
       << "\n";
  for (i = 0; i < n; i++) cout << res[i] << " ";
  return 0;
}
