#include <bits/stdc++.h>
using namespace std;
const unsigned long long int mod = 1e9 + 7;
const long long int inf = (long long int)1e18 + 2;
const long long int N = (long long int)1e5 + 2;
vector<long long int> graph[2002];
long long int a[2002], c[2002];
vector<long long int> la[2002];
long long int ko = 0;
bool flag = true;
vector<long long int> dfs(long long int index) {
  vector<long long int> ans;
  for (auto x : graph[index]) {
    vector<long long int> t = dfs(x);
    for (auto y : t) ans.push_back(y);
  }
  if (c[index] > ans.size()) {
    cout << "NO" << '\n';
    exit(0);
  }
  ans.push_back(index);
  long long int cur = index;
  for (long long int i = c[index]; i < ans.size(); i++) {
    swap(cur, ans[i]);
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  ko = n;
  long long int parent[n], idx = 0;
  for (long long int i = 0; i < n; i++)
    cin >> parent[i] >> c[i], (parent[i] == 0) ? parent[i] = i + 1, idx = i : 1;
  for (long long int i = 0; i < n; i++) {
    parent[i]--;
    if (parent[i] != i) graph[parent[i]].push_back(i);
  }
  vector<long long int> ans = dfs(idx);
  cout << "YES" << '\n';
  for (long long int i = 0; i < n; i++) a[ans[i]] = i + 1;
  for (long long int i = 0; i < n; i++) cout << a[i] << ' ';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
