#include <bits/stdc++.h>
using namespace std;
const int mx = 2e3 + 5;
int c[mx], h[mx], color[mx], child[mx];
vector<int> v[mx];
vector<int> cst[mx];
bool vis[mx];
void dfs(int x) {
  vis[x] = 1;
  child[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (!vis[v[x][i]]) {
      dfs(v[x][i]);
      child[x] += child[v[x][i]];
    }
  }
}
void dfs2(int x) {
  vis[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (!vis[v[x][i]]) {
      dfs2(v[x][i]);
      for (int j = 0; j < cst[v[x][i]].size(); j++)
        cst[x].push_back(cst[v[x][i]][j]);
    }
  }
  cst[x].insert(cst[x].begin() + c[x], x);
}
void solve() {
  int n;
  cin >> n;
  int root;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    c[i] = y;
    color[i] = 1;
    if (x != 0) {
      v[x].push_back(i);
      v[i].push_back(x);
    } else
      root = i;
  }
  dfs(root);
  for (int i = 1; i <= n; i++) {
    if (c[i] >= child[i]) {
      cout << "NO";
      return;
    }
  }
  memset(vis, false, sizeof vis);
  dfs2(root);
  for (int i = 0; i < cst[root].size(); i++) color[cst[root][i]] = i + 1;
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    cout << color[i] << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}
