#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(vector<T> v) {
  for (long long int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
const long long int N = 2000;
vector<int> order[N + 5];
vector<long long int> c(N + 5);
vector<long long int> graph[N + 5];
vector<int> ans(N + 5);
void add(long long int a, long long int b) {
  for (long long int i = 0; i < order[b].size(); i++)
    order[a].push_back(order[b][i]);
}
void dfs(long long int node, long long int parent) {
  for (long long int i = 0; i < graph[node].size(); i++) {
    long long int neighbour = graph[node][i];
    if (neighbour != parent) {
      dfs(neighbour, node);
      add(node, neighbour);
    }
  }
  if (c[node] > order[node].size()) {
    cout << "NO" << endl;
    exit(0);
  }
  order[node].insert(order[node].begin() + c[node], node);
}
long long int n;
void solve() {
  cin >> n;
  long long int root;
  for (long long int i = 1; i <= n; i++) {
    long long int x, y;
    cin >> x >> y;
    if (x) {
      graph[x].push_back(i);
    } else
      root = i;
    c[i] = y;
  }
  dfs(root, -1);
  for (long long int i = 0; i < n; i++) ans[order[root][i]] = i + 1;
  cout << "YES" << endl;
  for (long long int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
