#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
int c[N], ans[N];
vector<int> e[N];
vector<int> dfs(int u) {
  vector<int> res;
  for (auto v : e[u]) {
    vector<int> temp = dfs(v);
    res.insert(res.end(), temp.begin(), temp.end());
  }
  if (c[u] > res.size()) {
    puts("NO");
    exit(0);
  }
  res.insert(res.begin() + c[u], u);
  return res;
}
int main() {
  int n, rt;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x >> c[i];
    if (x == 0) rt = i;
    e[x].push_back(i);
  }
  vector<int> s = dfs(rt);
  puts("YES");
  for (int i = 0; i < s.size(); i++) ans[s[i]] = i + 1;
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
