#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long double PI = 4 * atan(1);
int n, p[2001], c[2001], size[2001], r, flag, ans[2001];
vector<int> v[2001];
int dfs(int i) {
  for (int a : v[i]) {
    size[i] += dfs(a);
  }
  size[i]++;
  return size[i];
}
void dfs2(int i, vector<int> cur) {
  if (c[i] >= cur.size()) {
    flag = 1;
    return;
  }
  ans[i] = cur[c[i]], cur.erase(cur.begin() + c[i]);
  int cnt = 0;
  for (int a : v[i]) {
    vector<int> V;
    for (int j = 0; j < size[a]; j++) V.push_back(cur[cnt++]);
    dfs2(a, V);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> p[i] >> c[i];
    if (p[i] == 0) r = i;
    v[p[i]].push_back(i);
  }
  dfs(r);
  vector<int> cur;
  for (int i = 1; i < n + 1; i++) cur.push_back(i);
  dfs2(r, cur);
  if (flag) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  for (int i = 1; i < n + 1; i++) cout << ans[i] << " ";
  return 0;
}
