#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T>
void printv(const vector<T> &s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    cout << s[i];
    if (i == (int)(s.size()) - 1)
      cout << endl;
    else
      cout << " ";
  }
}
template <typename T>
struct BinaryIndexedTree {
  vector<T> data;
  BinaryIndexedTree(int sz) { data.assign(++sz, 0); }
  T sum(int k) {
    T ret = 0;
    for (++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(int k, T x) {
    for (++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
vi a;
vector<bool> sel;
bool dfs(int n, int now, int prev, vvi &tr, BinaryIndexedTree<int> &bit,
         const vi &c) {
  bool res = false;
  for (int i = 0; i < n; ++i) {
    if (sel[i]) continue;
    int cnt = bit.sum(i) - 1;
    if (cnt == c[now]) {
      a[now] = i + 1;
      sel[i] = true;
      bit.add(i, -1);
      res = true;
      break;
    }
  }
  if (!res) return res;
  for (int i = 0; i < (int)(tr[now].size()); ++i) {
    int nxt = tr[now][i];
    if (nxt == prev) continue;
    res &= dfs(n, nxt, now, tr, bit, c);
  }
  if (bit.sum(a[now] - 1) != 0) return false;
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vi p(n), c(n);
  int root = 0;
  for (int i = 0; i < n; ++i) {
    cin >> p[i] >> c[i];
    p[i]--;
    if (p[i] == -1) root = i;
  }
  vvi tr(n);
  for (int i = 0; i < n; ++i) {
    if (p[i] != -1) {
      tr[p[i]].push_back(i);
    }
  }
  BinaryIndexedTree<int> bit(n + 1);
  for (int i = 0; i < n; ++i) {
    bit.add(i, 1);
  }
  a.clear();
  a.resize(n);
  sel.clear();
  sel.resize(n, false);
  bool ok = dfs(n, root, -1, tr, bit, c);
  if (ok) {
    cout << "YES" << endl;
    printv(a);
  } else {
    cout << "NO" << endl;
  }
}
