#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 1e18;
const int MOD = 998244353;
const long double PI = atan(1.0) * 4L;
const int MAXINT = 2000 + 1;
int dp[MAXINT], c[MAXINT], val[MAXINT];
vector<int> G[MAXINT];
int N, A[MAXINT];
struct STN {
  int val = 0;
  void merge(STN& L, STN& R) { val = L.val + R.val; }
  void operator=(int a) { val = a; }
};
STN ST[4 * MAXINT];
void STB(int id = 1, int l = 0, int r = N) {
  if (r - l < 2) {
    ST[id] = A[l];
    return;
  }
  int m = (l + r) >> 1, L = id << 1, R = L | 1;
  STB(L, l, m);
  STB(R, m, r);
  ST[id].merge(ST[L], ST[R]);
}
STN STQ(int x, int y, int id = 1, int l = 0, int r = N) {
  if (x == l && y == r) return ST[id];
  int m = (l + r) >> 1, L = id << 1, R = L | 1;
  if (x >= m) return STQ(x, y, R, m, r);
  if (y <= m) return STQ(x, y, L, l, m);
  STN res, ln = STQ(x, m, L, l, m), rn = STQ(m, y, R, m, r);
  return res.merge(ln, rn), res;
}
void STU(int p, int x, int id = 1, int l = 0, int r = N) {
  if (r - l < 2) {
    ST[id] = x;
    return;
  }
  int m = (l + r) >> 1, L = id << 1, R = L | 1;
  if (p < m)
    STU(p, x, L, l, m);
  else
    STU(p, x, R, m, r);
  ST[id].merge(ST[L], ST[R]);
}
int kth(int k, int id = 1, int l = 0, int r = N) {
  if (r - l < 2) {
    ST[id] = 0;
    return l;
  }
  int m = (l + r) >> 1, L = id << 1, R = L | 1;
  int cntL = ST[L].val, ans;
  if (cntL >= k)
    ans = kth(k, L, l, m);
  else
    ans = kth(k - cntL, R, m, r);
  ST[id].merge(ST[L], ST[R]);
  return ans;
}
void dfsAssign(int v) {
  val[v] = kth(c[v]);
  for (int w : G[v]) dfsAssign(w);
}
int dfsSubTree(int v) {
  dp[v] = 1;
  for (int w : G[v]) dp[v] += dfsSubTree(w);
  return dp[v];
}
int main() {
  int n;
  scanf("%d", &n);
  N = n + 1;
  for (int i = 1; i < n + 1; i++) A[i] = 1;
  STB();
  int root = 0, p;
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &p), scanf("%d", &c[i]);
    c[i]++;
    if (p == 0)
      root = i;
    else
      G[p].push_back(i);
  }
  dfsSubTree(root);
  bool valid = true;
  for (int i = 1; i < n + 1; i++)
    if (c[i] > dp[i]) valid = false;
  if (!valid)
    printf("NO\n");
  else {
    printf("YES\n");
    dfsAssign(root);
    for (int i = 1; i < n + 1; i++) printf("%d ", val[i]);
    printf("\n");
  }
  return 0;
}
