#include <bits/stdc++.h>
using namespace std;
const int n = 2005;
int N, M, K;
vector<int> G[n];
int C[n], A[n];
bool O[n];
bool pos = true;
void DFS(int v) {
  int c = C[v] + 1;
  for (int i = 0; i < N; ++i) {
    if (!O[i]) A[v] = i, c--;
    if (c == 0) break;
  }
  if (c != 0) pos = false;
  O[A[v]] = true;
  for (int c : G[v]) {
    DFS(c);
  }
  for (int i = 0; i < A[v]; ++i) {
    pos = pos && O[i];
  }
}
int main() {
  cin >> N;
  int root = -1;
  for (int i = 0; i < N; ++i) {
    int p;
    cin >> p >> C[i];
    p--;
    if (p == -1)
      root = i;
    else
      G[p].push_back(i);
  }
  DFS(root);
  if (pos) {
    cout << "YES\n";
    for (int i = 0; i < N; ++i) {
      cout << A[i] + 1 << " ";
    }
    cout << endl;
  } else {
    cout << "NO\n";
  }
  return 0;
}
