#include <bits/stdc++.h>
using namespace std;
int a[2005];
int p[2005];
int c[2005];
vector<int> E[2005];
vector<int> dfs(int x) {
  vector<int> ans;
  for (int i = 0; i < E[x].size(); i++) {
    vector<int> tmp = dfs(E[x][i]);
    for (int j = 0; j < tmp.size(); j++) {
      ans.push_back(tmp[j]);
    }
  }
  if (x == 0) return ans;
  if (ans.size() < c[x]) {
    cout << "NO" << endl;
    exit(0);
  }
  vector<int> newans;
  for (int i = 0; i < c[x]; i++) {
    newans.push_back(ans[i]);
  }
  newans.push_back(x);
  for (int i = c[x]; i < ans.size(); i++) {
    newans.push_back(ans[i]);
  }
  ans = newans;
  return ans;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &p[i], &c[i]);
    E[p[i]].push_back(i);
  }
  vector<int> ans = dfs(0);
  cout << "YES" << endl;
  for (int i = 0; i < ans.size(); i++) {
    a[ans[i]] = i + 1;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
  return 0;
}
