#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, arr[2001], a, b, num[2001];
vector<int> adj[2001];
bool good = true;
vector<int> dfs(int src = b, int p = 0) {
  int cnt = 0;
  vector<int> chs;
  for (int ch : adj[src]) {
    if (ch == p) {
      continue;
    }
    for (int x : dfs(ch, src)) {
      if (cnt == arr[src]) {
        chs.emplace_back(src);
        cnt++;
      }
      chs.emplace_back(x);
      cnt++;
    }
  }
  if (arr[src] > cnt) {
    good = false;
  }
  if (chs.empty()) {
    if (arr[src]) {
      good = false;
    }
    chs.emplace_back(src);
  } else if (cnt == arr[src]) {
    chs.emplace_back(src);
  }
  return chs;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &a, &arr[i]);
    if (a) {
      adj[a].emplace_back(i);
      adj[i].emplace_back(a);
    } else {
      b = i;
    }
  }
  vector<int> ans = dfs();
  if (!good) {
    puts("NO");
    return 0;
  }
  int c = 1;
  for (int x : ans) {
    num[x] = c++;
  }
  puts("YES");
  for (int i = 1; i <= n; ++i) {
    printf("%d%c", num[i], " \n"[i == n]);
  }
  return 0;
}
