#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O3")
const int MAXN = (int)3e3;
vector<int> G[MAXN];
vector<int> kolejnosc[MAXN];
int C[MAXN];
int odp[MAXN];
int n;
int root;
void concat(vector<int> &A, vector<int> B) {
  for (auto b : B) A.push_back(b);
}
void koniec() {
  cout << "NO"
       << "\n";
  exit(0);
}
void dfs(int x) {
  for (int y : G[x]) {
    dfs(y);
    concat(kolejnosc[x], kolejnosc[y]);
  }
  if (kolejnosc[x].size() < C[x]) koniec();
  kolejnosc[x].insert(kolejnosc[x].begin() + C[x], x);
}
void input() {
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    int a;
    cin >> a;
    if (a > 0) {
      a--;
      G[a].push_back(i);
    } else
      root = i;
    cin >> C[i];
  }
}
int main() {
  ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10);
  input();
  dfs(root);
  cout << "YES"
       << "\n";
  for (int i = 0; i < (n); ++i) {
    odp[kolejnosc[root][i]] = i + 2;
  }
  for (int i = 0; i < (n); ++i) cout << odp[i] << " ";
  cout << "\n";
}
