#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 3;
int t[MAXN];
int ans[MAXN];
set<int> q;
vector<int> v[MAXN];
int preDFS(int x) {
  int ret = 0;
  for (auto it : v[x]) ret += preDFS(it);
  if (ret < t[x]) {
    printf("NO");
    exit(0);
  }
  return ret + 1;
}
void DFS(int x) {
  if (t[x] == 0) {
    ans[x] = *q.begin();
    q.erase(*q.begin());
  } else {
    int licz = 0;
    for (auto it : q) {
      if (licz == t[x]) {
        ans[x] = it;
        break;
      }
      licz++;
    }
    q.erase(ans[x]);
  }
  for (auto it : v[x]) DFS(it);
}
int main() {
  int n, p, x = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &p, &t[i]);
    if (p == 0) x = i;
    v[p].push_back(i);
    q.insert(i);
  }
  preDFS(x);
  DFS(x);
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
