#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> edges;
vector<int> large;
bool ok = true;
vector<pair<long long, long long>> dfs(int cur) {
  vector<pair<long long, long long>> child;
  for (int i : edges[cur]) {
    auto temp = dfs(i);
    child.insert(child.end(), temp.begin(), temp.end());
  }
  sort(child.begin(), child.end());
  vector<pair<long long, long long>> res;
  int add = 0;
  if (large[cur] > child.size()) {
    ok = false;
  }
  for (auto it : child) {
    if (res.size() == large[cur]) {
      res.push_back({res.size() + 1, cur});
    }
    res.push_back({res.size() + 1, it.second});
  }
  if (res.size() == child.size()) {
    res.push_back({res.size() + 1, cur});
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  edges.clear();
  edges.resize(n + 1);
  vector<pair<long long, long long>> in(n);
  for (auto& it : in) {
    cin >> it.first >> it.second;
  }
  int par = -1;
  large.clear();
  large.resize(n + 1);
  for (int i = 0; i < n; i++) {
    if (in[i].first != 0) {
      edges[in[i].first].push_back(i + 1);
    } else {
      par = i + 1;
    }
    large[i + 1] = in[i].second;
  }
  auto res = dfs(par);
  if (!ok) {
    cout << "NO" << endl;
    return;
  }
  cout << "YES" << endl;
  for (auto it : res) {
    large[it.second] = it.first;
  }
  for (int i = 1; i <= n; i++) {
    cout << large[i] << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
