#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
long long int modInverse(long long int a) { return power(a, 1000000007 - 2); }
const int N = 500023;
bool vis[N];
vector<int> adj[N];
long long int values[N];
long long int par[N];
long long int lower[N];
vector<long long int> s;
int cnt = 0;
void dfs(int curr) {
  long long int c = lower[curr];
  if (c >= s.size()) {
    cout << "NO\n";
    exit(0);
  }
  values[curr] = s[c];
  s.erase(s.begin() + c);
  for (auto it : adj[curr]) dfs(it);
}
void dfs2(int curr, int val) {
  if (values[curr] < val) cnt++;
  for (auto it : adj[curr]) dfs2(it, val);
}
void check(int curr) {
  long long int val = values[curr];
  cnt = 0;
  for (auto it : adj[curr]) {
    dfs2(it, val);
  }
  if (cnt != lower[curr]) {
    cout << "NO\n";
    exit(0);
  }
}
void solve() {
  long long int n;
  cin >> n;
  for (int i = 1; i <= n; i++) s.push_back(i);
  long long int root = 0;
  for (int i = 1; i <= n; i++) {
    long long int a, b;
    cin >> a >> b;
    if (a == 0) {
      root = i;
      par[root] = 0;
    } else {
      par[i] = a;
      adj[a].push_back(i);
    }
    lower[i] = b;
  }
  dfs(root);
  for (int i = 1; i <= n; i++) check(i);
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    cout << values[i] << ' ';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  int t = 0;
  while (t++ < T) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
