#include <bits/stdc++.h>
using namespace std;
list<long long> gr[2005];
long long val[2005], sz[2005];
bool vis[2005];
vector<long long> ve[2005];
void add(vector<long long>& a, vector<long long>& b) {
  for (auto x : b) {
    a.push_back(x);
  }
}
void dfs(long long u) {
  vis[u] = 1;
  for (auto x : gr[u]) {
    if (!vis[x]) {
      dfs(x);
      add(ve[u], ve[x]);
      sz[u] += sz[x];
    }
  }
  if (val[u] > sz[u] - 1) {
    cout << "NO";
    exit(0);
  }
  ve[u].insert(ve[u].begin() + val[u], u);
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, root;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    sz[i] = 1;
    long long u, v;
    cin >> u >> v;
    val[i] = v;
    if (u) {
      gr[i].push_back(u);
      gr[u].push_back(i);
    } else {
      root = i;
    }
  }
  dfs(root);
  long long ans[n + 1], i = 1;
  for (auto x : ve[root]) {
    ans[x] = i++;
  }
  cout << "YES"
       << "\n";
  for (long long i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
