#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adjl;
map<int, int> ss;
vector<int> ans;
vector<int> c_val;
vector<int> subt_sz;
void dfss(int u) {
  int tmp = 0;
  for (int i = 0; i < adjl[u].size(); i++) {
    int v = adjl[u][i];
    dfss(v);
    tmp += subt_sz[v];
  }
  tmp++;
  subt_sz[u] = tmp;
}
void dfs(int u) {
  auto itr = ss.begin();
  int i = 0;
  for (; i < c_val[u]; i++, itr++)
    ;
  ans[u] = (*itr).first;
  ss.erase((*itr).first);
  for (int i = 0; i < adjl[u].size(); i++) {
    int v = adjl[u][i];
    dfs(v);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  c_val.resize(n);
  ans.resize(n);
  subt_sz.resize(n);
  int parent[n];
  for (int i = 0; i < n; i++) {
    cin >> parent[i] >> c_val[i];
    parent[i]--;
  }
  adjl.resize(n);
  int root = -1;
  for (int i = 0; i < n; i++) {
    if (parent[i] == -1) {
      root = i;
    } else {
      adjl[parent[i]].push_back(i);
    }
    ss[i + 1] = 1;
  }
  dfss(root);
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (subt_sz[i] <= c_val[i]) {
      flag = false;
      break;
    }
  }
  if (!flag) {
    cout << "NO\n";
    return 0;
  }
  dfs(root);
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
  return 0;
}
