#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
long long t, n, x, y, k, m;
string s;
long long a[2004], b[2004], c[2004];
char chr[206];
long long pow(long long base, long long power, const long long mod) {
  long long ans = 1;
  while (power) {
    if (power & 1) {
      ans *= base;
      ans %= MOD;
    }
    power >>= 1;
    base *= base;
    base %= MOD;
  }
  return ans;
}
ostream& operator<<(ostream& ostr, pair<int, int> p) {
  ostr << "(" << p.first << "," << p.second << ")";
  return ostr;
}
long long flg = 0;
long long rt, ok;
vector<vector<int> > adj;
vector<int> ans, v;
long long dfs(long long u) {
  long long res = 0;
  for (int i = 0; i < (long long)adj[u].size(); ++i) {
    res += dfs(adj[u][i]) + 1;
  }
  return a[u] = res;
}
void dfs2(long long u) {
  ans[u] = v[c[u]];
  v.erase(v.begin() + c[u]);
  for (int i = 0; i < (long long)adj[u].size(); ++i) {
    dfs2(adj[u][i]);
  }
}
void solve() {
  cin >> n;
  adj = vector<vector<int> >(n + 1, vector<int>());
  v = vector<int>();
  ans = vector<int>(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    a[i] = 0;
  }
  long long p;
  for (int i = 1; i <= n; ++i) {
    cin >> p >> c[i];
    if (!p) {
      rt = i;
    } else {
      adj[p].push_back(i);
    }
  }
  ok = 1;
  dfs(rt);
  for (int i = 1; i <= n; ++i) {
    if (c[i] > a[i]) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "YES\n";
    for (int i = 1; i <= n; ++i) {
      v.push_back(i);
    }
    dfs2(rt);
    for (int i = 1; i <= n; ++i) {
      cout << ans[i] << " ";
    }
    cout << endl << flush;
  } else {
    cout << "NO\n";
  }
}
int main(int argc, char const* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
