#include <bits/stdc++.h>
using namespace std;
int p[2010], c[2010];
vector<int> adj[2010];
int subsize[2010];
vector<int> v;
int dfs(int u) {
  int ret = 0;
  for (auto v : adj[u]) {
    ret += dfs(v) + 1;
  }
  return subsize[u] = ret;
}
int ans[2010];
void getans(int u) {
  ans[u] = v[c[u]];
  v.erase(v.begin() + c[u]);
  for (auto v : adj[u]) {
    getans(v);
  }
}
int main() {
  int n;
  cin >> n;
  int root;
  for (int i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    if (p[i] == 0) root = i;
    adj[p[i]].push_back(i);
  }
  dfs(root);
  bool ok = true;
  for (int i = 1; i <= n; i++) {
    if (subsize[i] < c[i]) {
      ok = false;
      break;
    }
  }
  if (!ok) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    for (int i = 1; i <= n; i++) v.push_back(i);
    getans(root);
    for (int i = 1; i <= n; i++) {
      cout << ans[i] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
