#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int sz[2005];
int nd[2005];
vector<int> g[2005];
int ans[2005];
int dfs1(int now) {
  sz[now] = 1;
  for (auto i : g[now]) {
    sz[now] += dfs1(i);
  }
  return sz[now];
}
void dfs2(int now, vector<int> v) {
  ans[now] = v[nd[now]];
  int ptr = 0;
  for (auto i : g[now]) {
    vector<int> vv;
    while ((int)vv.size() < sz[i]) {
      if (ptr == nd[now])
        ;
      else
        vv.push_back(v[ptr]);
      ptr++;
    }
    dfs2(i, vv);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  while (cin >> n) {
    int rt;
    for (int i = 1; i < n + 1; i++) {
      int add;
      cin >> add;
      if (add == 0) rt = i;
      g[add].push_back(i);
      cin >> nd[i];
    }
    dfs1(rt);
    for (int i = 1; i < n + 1; i++) {
      if (nd[i] >= sz[i]) {
        cout << "NO\n";
        exit(0);
      }
    }
    vector<int> v;
    for (int i = 1; i < n + 1; i++) {
      v.push_back(i);
    }
    dfs2(rt, v);
    cout << "YES\n";
    for (int i = 1; i < n + 1; i++) {
      cout << ans[i] << ' ';
    }
    cout << '\n';
  }
}
