#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
void bugp(const pair<T, V> &x) {
  cerr << '{' << x.first << ", " << x.second << '}' << endl;
}
template <typename T, typename U, typename V>
void bugpp(const pair<T, pair<U, V> > &x) {
  cerr << '{' << x.first << ", {" << x.second.first << ", " << x.second.second
       << "}}" << endl;
}
template <typename T>
bool maximize(T &x, const T &y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
template <typename T>
bool minimize(T &x, const T &y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
const int N = 2002;
int n, C[N], A[N], subsz[N];
bool chk[N], answer = 1;
vector<int> child[N];
int getNext(int idx) {
  int ans = -1;
  for (int i = 1, _n = (n); i <= _n; ++i) {
    if (!chk[i]) --idx;
    if (!idx) {
      ans = i;
      break;
    }
  }
  return ans;
}
void DFS(int u) {
  subsz[u] = 1;
  A[u] = getNext(C[u] + 1);
  if (A[u] == -1)
    answer = 0;
  else
    chk[A[u]] = 1;
  for (int &v : child[u]) {
    DFS(v);
    subsz[u] += subsz[v];
  }
  if (C[u] >= subsz[u]) answer = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int root;
  for (int i = 1, _n = (n); i <= _n; ++i) {
    int p;
    cin >> p >> C[i];
    if (p)
      child[p].push_back(i);
    else
      root = i;
  }
  DFS(root);
  if (!answer)
    cout << "NO";
  else {
    cout << "YES\n";
    for (int i = 1, _n = (n); i <= _n; ++i) cout << A[i] << ' ';
  }
  return 0;
}
