#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
clock_t startTime;
void getTimeTaken() {
  cerr << "\nTime taken : " << (double)(clock() - startTime) / CLOCKS_PER_SEC
       << " s";
}
vector<long long> c;
vector<vector<long long>> tree;
vector<long long> dfs(long long u) {
  vector<long long> ret;
  for (auto v : tree[u]) {
    vector<long long> temp = dfs(v);
    for (auto it : temp) {
      ret.push_back(it);
    }
  }
  if (ret.size() < c[u]) {
    cout << "NO";
    exit(0);
  }
  ret.insert(ret.begin() + c[u], u);
  return ret;
}
int32_t main() {
  startTime = clock();
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  ;
  long long n;
  cin >> n;
  tree.resize(n + 1);
  c.resize(n + 1);
  long long root = -1;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x >> c[i];
    x--;
    if (x == -1) {
      root = i;
    } else {
      tree[x].push_back(i);
    }
  }
  vector<long long> order = dfs(root);
  assert(order.size() == n);
  vector<long long> ans(n + 1);
  for (long long i = 0; i < n; i++) {
    ans[order[i]] = i + 1;
  }
  cout << "YES\n";
  for (long long i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
}
