#include <bits/stdc++.h>
using namespace std;
long long int minf = numeric_limits<long long int>::min();
long long int inf = numeric_limits<long long int>::max();
const long long int N = 500007;
const long long int MOD = 100000007;
int fst(vector<vector<int>> &adj, int r, vector<int> &st) {
  int t = 0;
  for (auto i : adj[r]) {
    t += fst(adj, i, st);
  }
  st[r] = t;
  return t + 1;
}
vector<int> ff(vector<vector<int>> &adj, int rt, vector<int> &ct,
               vector<int> &st) {
  vector<int> v, r;
  for (auto i : adj[rt]) {
    if (st[i] < ct[i]) {
      cout << "NO";
      exit(0);
    }
    r = ff(adj, i, ct, st);
    v.insert(v.end(), r.begin(), r.end());
  }
  v.insert(v.begin() + ct[rt], rt);
  return v;
}
void sol() {
  long long int t = 0, n = 0, a = 0, b = 0, c = 0, d = 0, k = 0, f = 0, m = 0,
                r = 0, p;
  cin >> n;
  vector<int> ct(n + 1), ret, ans(n + 1);
  vector<vector<int>> adj(n + 1);
  vector<int> st(n + 1);
  st[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> p >> c;
    if (p != 0) {
      adj[p].push_back(i);
      ct[i] = c;
    } else {
      r = i;
      ct[i] = c;
    }
  }
  fst(adj, r, st);
  ret = ff(adj, r, ct, st);
  for (int i = 0; i < n; i++) {
    ans[ret[i]] = i + 1;
  }
  cout << "YES";
  cout << "\n";
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}
int main() {
  long long int t = 1;
  while (t--) {
    sol();
    cout << "\n";
    ;
  }
  return 0;
}
