#include <bits/stdc++.h>
using namespace std;
int dfs_call(vector<vector<int>> &graph, int root, vector<int> &values,
             int parent, bool &flag) {
  int sz = graph[root].size();
  int ans = 1;
  for (int j = 0; j < sz; j++) {
    if (graph[root][j] != parent) {
      ans += dfs_call(graph, graph[root][j], values, root, flag);
    }
  }
  if (ans <= values[root]) flag = true;
  return ans;
}
void dfs(vector<vector<int>> &graph, int root, vector<int> &values,
         vector<int> &ans, int parent, set<int> &s) {
  set<int>::iterator it = s.begin();
  for (int i = 0; i < values[root] && it != s.end(); i++) {
    set<int>::iterator temp = it;
    temp++;
    if (temp != s.end())
      it++;
    else {
      break;
    }
  }
  ans[root] = (*it);
  s.erase(it);
  int sz = graph[root].size();
  for (int j = 0; j < sz; j++) {
    if (graph[root][j] != parent) {
      dfs(graph, graph[root][j], values, ans, root, s);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, a, b;
  cin >> n;
  vector<int> values(n + 1), ans(n + 1);
  vector<vector<int>> graph(n + 1);
  int root = a;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    graph[a].push_back(i);
    values[i] = b;
    if (a == 0) root = i;
  }
  bool flag = false;
  dfs_call(graph, root, values, -1, flag);
  if (flag) {
    cout << "NO" << endl;
    return 0;
  }
  set<int> s;
  for (int i = 1; i <= n; i++) s.insert(i);
  dfs(graph, root, values, ans, -1, s);
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
