#include <bits/stdc++.h>
using namespace std;
int n;
void dfs(vector<vector<int> > &G, int u, vector<int> &sz) {
  for (auto &v : G[u]) {
    dfs(G, v, sz);
    sz[u] += sz[v];
  }
}
void solve(vector<vector<int> > &G, int u, vector<int> &r, vector<int> &sz,
           vector<int> &c) {
  if (c[u] >= sz[u]) {
    cout << "NO\n";
    exit(0);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (r[i] != -1) continue;
    if (cnt == c[u]) {
      r[i] = u;
      break;
    }
    cnt++;
  }
  for (auto &v : G[u]) solve(G, v, r, sz, c);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  vector<vector<int> > G(n);
  vector<int> c(n);
  int rt = -1;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p >> c[i];
    p--;
    if (p == -1) {
      rt = i;
      continue;
    }
    G[p].push_back(i);
  }
  vector<int> r(n, -1);
  vector<int> sz(n, 1);
  dfs(G, rt, sz);
  solve(G, rt, r, sz, c);
  map<int, int> ans;
  for (int i = 0; i < n; i++) {
    ans[r[i]] = i + 1;
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
}
