#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
const int N = 2007;
int n, P[N], C[N], root, sz[N], val[N];
vector<int> G[N];
vector<int> ord;
int dfs(int v) {
  for (auto u : G[v]) sz[v] += dfs(u);
  ord.push_back(v);
  return ++sz[v];
}
void add(int v, int x, int y) {
  if (val[v] > x) val[v] += y;
  for (auto u : G[v]) add(u, x, y);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> P[i] >> C[i];
    if (P[i] == 0)
      root = i;
    else
      G[P[i]].push_back(i);
  }
  dfs(root);
  for (int i = 1; i <= n; i++) {
    if (!(0 <= C[i] && C[i] < sz[i])) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (auto v : ord) {
    int sm = 0;
    for (auto u : G[v]) {
      add(u, 0, sm);
      sm += sz[u];
    }
    val[v] = C[v] + 1;
    for (auto u : G[v]) {
      add(u, C[v], 1);
    }
  }
  for (int i = 1; i <= n; i++) cout << val[i] << " ";
  cout << "\n";
  return 0;
}
