#include <bits/stdc++.h>
using namespace std;
mt19937 Rand(time(0));
template <class A, class B>
void Max(A &a, B b) {
  a = ((a < b) ? b : a);
}
template <class A, class B>
void Min(A &a, B b) {
  a = ((a < b) ? a : b);
}
template <class T>
T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
template <class T>
inline void Write(T x) {
  if (x < 0) {
    putchar('-');
    x *= -1;
  }
  (x > 9) ? WriteInt(x / 10) : putchar(x % 10 + '0');
}
template <class T>
inline void Read(T &x) {
  char c;
  for (c = getchar(); (c > '9' || c < '0') && c != '-'; c = getchar())
    ;
  T y;
  if (c == '-')
    x = 0, y = -1;
  else
    x = c - '0', y = 1;
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= y;
}
const int maxn = 2e3 + 5;
const long long maxc = 1e9 + 7;
using Array = int[maxn];
vector<int> adj[maxn];
int root, n;
Array c, f, a;
struct Fenwick_tree {
  Array bit;
  void up(int x, int val) {
    for (; x < maxn; x += x & -x) bit[x] += val;
  }
  int get(int x) {
    int res = 0;
    for (; x > 0; x -= x & -x) res += bit[x];
    return res;
  }
} BIT;
int calc(int q) {
  int r = n, l = 0;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (BIT.get(mid) > q)
      r = mid;
    else
      l = mid;
  }
  return r;
}
void dfs(int u) {
  f[u] = 1;
  int x = calc(c[u]);
  BIT.up(x, -1);
  a[u] = x;
  for (auto v : adj[u]) {
    dfs(v);
    f[u] += f[v];
  }
  if (f[u] > c[u]) return;
  cout << "NO";
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  Read(n);
  for (int i = 1; i <= n; i++) {
    int x;
    Read(x), Read(c[i]);
    if (x)
      adj[x].push_back(i);
    else
      root = i;
    BIT.up(i, 1);
  }
  dfs(root);
  cout << "YES"
       << "\n";
  for (int i = 1; i <= n; i++) cout << a[i] << " ";
  return 0;
}
