#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 1000002;
const double PI = 4 * atan(1);
const double eps = 1e-7;
const long long oo = 1e18;
long long n;
long long c[N];
vector<long long> adj[N];
vector<pair<long long, long long> > troll[N];
long long root;
vector<long long> leafs;
long long par[N];
long long ans[N];
vector<long long> deg[N];
long long ind[N];
bool cond = false;
void dfs(long long src, long long par) {
  long long res = 0;
  for (auto t : adj[src]) {
    if (t == par) continue;
    dfs(t, src);
    res++;
    ind[src]++;
  }
  if (res == 0) leafs.push_back(src);
}
void dfs2(long long src, long long par) {
  vector<long long> v;
  for (auto t : adj[src]) {
    if (t == par) continue;
    dfs2(t, src);
    for (auto u : deg[t]) {
      v.push_back(u);
    }
  }
  sort((v).begin(), (v).end());
  long long z = v.size();
  if (c[src] == 0) {
    if (v.size() != 0 && v[0] < ans[src]) {
      cond = true;
    }
  } else if (v.size() == 0) {
    if (c[src] > 0) {
      cond = true;
    }
  } else if (c[src] > v.size()) {
    cond = true;
  } else if (c[src] == v.size()) {
    if (v[z - 1] >= ans[src]) cond = true;
  } else {
    if (v[c[src]] < ans[src] || v[c[src] - 1] >= ans[src]) {
      cond = true;
    }
  }
  v.push_back(ans[src]);
  deg[src] = v;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    if (x == 0)
      root = i;
    else {
      par[i] = x - 1;
    }
    x--;
    adj[x].push_back(i);
    adj[i].push_back(x);
    c[i] = y;
  }
  dfs(root, -1);
  queue<long long> q;
  long long cnt = 1;
  for (int i = 0; i < leafs.size(); i++) {
    q.push(leafs[i]);
  }
  while (!q.empty()) {
    long long ras = q.front();
    q.pop();
    sort((troll[ras]).begin(), (troll[ras]).end());
    long long z = troll[ras].size();
    if (z <= c[ras]) {
      if (z > 0)
        troll[ras].push_back({(troll[ras][z - 1].first) + 1, ras});
      else
        troll[ras].push_back({cnt++, ras});
    } else {
      long long w = c[ras];
      long long x = troll[ras][w].first;
      for (int i = w; i < troll[ras].size(); i++) {
        troll[ras][i].first++;
      }
      troll[ras].push_back({x, ras});
      sort((troll[ras]).begin(), (troll[ras]).end());
    }
    if (par[ras] != -1) {
      long long w = par[ras];
      long long z = troll[w].size();
      long long b = troll[ras].size();
      sort((troll[w]).begin(), (troll[w]).end());
      long long a = 0;
      if (z > 0) {
        a = troll[w][z - 1].first - troll[ras][0].first + 1;
      }
      for (auto t : troll[ras]) {
        troll[w].push_back({t.first + a, t.second});
      }
      ind[par[ras]]--;
      if (ind[par[ras]] == 0) {
        q.push(par[ras]);
      }
    }
  }
  for (auto t : troll[root]) {
    ans[t.second] = t.first;
  }
  dfs2(root, -1);
  if (cond) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
