#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, root, sum, cnt, ans, p[2005], c[2005], a[2005], sz[2005],
    b[2005], res[2005];
vector<int> edges[2005];
void dfs(int x, int p) {
  sz[x] = 1;
  for (auto y : edges[x]) {
    dfs(y, x);
    sz[x] += sz[y];
  }
  b[++cnt] = x;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    cin >> p[i] >> c[i];
    if (p[i] != 0)
      edges[p[i]].push_back(i);
    else
      root = i;
  }
  dfs(root, -1);
  for (int i = (1); i <= (n); i++) {
    if (c[i] > sz[i] - 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  int num = 1;
  for (int i = (1); i <= (n); i++) {
    x = b[i];
    if (sz[x] == 1) {
      a[i] = num;
      continue;
    }
    int st = i - sz[x] + 1;
    vector<pair<int, int> > v;
    for (int j = (st); j <= (i - 1); j++) {
      v.push_back({a[j], j});
    }
    sort((v).begin(), (v).end());
    int it = 0;
    int hi = c[x] == 0 ? 1 : v[c[x] - 1].first + 1;
    a[i] = hi;
    if (v.size() > c[x] && v[c[x]].first <= a[i]) {
      int diff = a[i] + 1 - v[c[x]].first;
      for (int j = (c[x]); j <= ((int)v.size() - 1); j++) {
        a[v[j].second] += diff;
      }
    }
    num = max(num, a[i]);
  }
  for (int i = (1); i <= (n); i++) res[b[i]] = a[i];
  for (int i = (1); i <= (n); i++) {
    cout << res[i] << ' ';
  }
  cout << endl;
  return 0;
}
