#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline int read() {
  int a = 0, b = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') b = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    a = (a << 3) + (a << 1) + c - '0';
    c = getchar();
  }
  return a * b;
}
const int INF = 0x3f3f3f3f;
const int N = 2e3 + 7;
vector<int> G[N];
int p[N], res[N], c[N];
int n;
vector<int> dfs(int x) {
  vector<int> ans;
  for (auto v : G[x]) {
    vector<int> tmp = dfs(v);
    for (auto val : tmp) ans.push_back(val);
  }
  if (x == 0) return ans;
  if (ans.size() < c[x]) {
    cout << "NO" << endl;
    exit(0);
  }
  vector<int> temp;
  for (register int i = (0); i <= (c[x] - 1); i++) temp.push_back(ans[i]);
  temp.push_back(x);
  for (register int i = (c[x]); i <= ((int)ans.size() - 1); i++)
    temp.push_back(ans[i]);
  ans = temp;
  return ans;
}
int main() {
  n = read();
  for (register int i = (1); i <= (n); i++) {
    p[i] = read(), c[i] = read();
    G[p[i]].push_back(i);
  }
  vector<int> ans = dfs(0);
  cout << "YES" << endl;
  for (register int i = (0); i <= (ans.size() - 1); i++) res[ans[i]] = i + 1;
  for (register int i = (1); i <= (n); i++) cout << res[i] << " ";
  cout << endl;
  return 0;
}
