#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400050;
const int MAXM = MAXN * 40;
const double pi = acos(-1.0);
const int mod = 1000000007;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
struct node {
  int to, c;
};
vector<node> v[2005];
int vis[2005], f = 0;
int pos[2005];
vector<int> dfs(int u, int fa) {
  vector<int> a;
  for (int i = 0; i < v[u].size(); i++) {
    int to = v[u][i].to;
    if (to == fa) continue;
    vector<int> b = dfs(to, u);
    for (int i = 0; i < b.size(); i++) a.push_back(b[i]);
  }
  if (vis[u] > a.size()) {
    f = 1;
  } else {
    a.insert(a.begin() + vis[u], u);
  }
  return a;
}
int main() {
  int n;
  scanf("%d", &n);
  int root;
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a > 0) {
      v[i].push_back(node{a, b});
      v[a].push_back(node{i, b});
    } else
      root = i;
    vis[i] = b;
  }
  vector<int> a = dfs(root, -1);
  if (f) {
    printf("NO\n");
  } else {
    int p = 1;
    for (int i = 0; i < a.size(); i++) {
      pos[a[i]] = p++;
    }
    printf("YES\n");
    for (int i = 1; i <= n; i++) {
      printf("%d", pos[i]);
      printf("%c", i < n ? ' ' : '\n');
    }
  }
  return 0;
}
