#include <bits/stdc++.h>
using namespace std;
int bPow(int v, int u, int mod) {
  if (!u) return 1;
  int res = bPow(v, u / 2, mod);
  res = (res * 1ll * res) % mod;
  if (u & 1) res = (res * 1ll * v) % mod;
  return res;
}
bool fb(long long x) { return 0; }
int bSearch(int l, int r) {
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (fb(m))
      l = m;
    else
      r = m;
  }
  if (fb(l + 1)) l++;
  if (!fb(l)) l = 0;
  return l;
}
void faster() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  if (0) {
    freopen(
        "a"
        ".in",
        "r", stdin);
    freopen(
        "a"
        ".out",
        "w", stdout);
  }
}
vector<int> prime;
bool notprime[1000010];
void resh() {
  int n = 1000010 - 10;
  for (int i = 2; i < n; i++)
    if (!notprime[i]) {
      prime.push_back(i);
      for (int j = i; j < n; j += i) notprime[j] = 1;
    }
}
int is_comp(long long p) {
  for (int i = 0; prime[i] * 1ll * prime[i] <= p; i++) {
    if (p % prime[i] == 0) return prime[i];
  }
  return 0;
}
bool is_prime(long long p) {
  for (int i = 0; prime[i] * 1ll * prime[i] <= p; i++) {
    if (p % prime[i] == 0) return 0;
  }
  return 1;
}
int gcd(int a, int b) {
  if (a > b) swap(a, b);
  if (!a) return b;
  return gcd(b % a, a);
}
int n, p, c[2200], r, t = 1, a[2200], x[2200], y[2200];
vector<int> g[2200];
vector<pair<int, int> > w;
bool bad;
void dfs(int v) {
  x[v] = a[v] = t++;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    dfs(to);
  }
  y[v] = t;
}
int main() {
  faster();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p >> c[i];
    if (p)
      g[p].push_back(i);
    else
      r = i;
  }
  dfs(r);
  for (int i = 1; i <= n; i++) {
    w.clear();
    for (int j = 1; j <= n; j++)
      if (x[i] < x[j] && y[i] >= y[j]) w.push_back(make_pair(a[j], j));
    if (c[i] > w.size()) {
      bad = 1;
      break;
    }
    if (!c[i]) continue;
    sort(w.begin(), w.end());
    int temp = w[c[i] - 1].first;
    a[w[0].second] = a[i];
    for (int j = 1; j < c[i]; j++) a[w[j].second] = w[j - 1].first;
    a[i] = temp;
  }
  if (bad)
    cout << "NO";
  else {
    cout << "YES\n";
    for (int i = 1; i <= n; i++) cout << a[i] << ' ';
  }
  return 0;
}
