#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long p = 1e9 + 7;
vector<int> children[2001];
int c[2001];
int n;
int root;
bool flag = false;
vector<pair<int, int> > trash;
void input() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p;
    if (p == 0) {
      root = i;
    } else {
      children[p].push_back(i);
    }
    cin >> c[i];
  }
}
vector<pair<int, int> > solve(int i) {
  if (flag) return trash;
  if (children[i].size() == 0) {
    if (c[i] != 0) {
      flag = true;
      return trash;
    }
    vector<pair<int, int> > v;
    v.push_back(make_pair(1, i));
    return v;
  }
  vector<pair<int, int> > vi;
  for (int u : children[i]) {
    vector<pair<int, int> > vu = solve(u);
    for (int j = 0; j < vu.size(); j++) {
      vi.push_back(vu[j]);
    }
  }
  if (c[i] > vi.size()) {
    flag = true;
    return trash;
  }
  int x = c[i];
  sort(vi.begin(), vi.end());
  for (int j = 0; j < vi.size(); j++) {
    if (j + 1 > x)
      vi[j].first = j + 2;
    else
      vi[j].first = j + 1;
  }
  vi.push_back(make_pair(x + 1, i));
  sort(vi.begin(), vi.end());
  return vi;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  vector<pair<int, int> > a = solve(root);
  if (flag) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  int ans[n + 1];
  for (int i = 0; i < n; i++) {
    ans[a[i].second] = a[i].first;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
