#include <bits/stdc++.h>
using namespace std;
template <class T>
int check_mod(T a, T b) {
  return (a % b) ? 1 : 0;
}
template <class T>
void maxi(T &a, T b) {
  a = max(a, b);
  return;
}
template <class T>
void mini(T &a, T b) {
  a = min(a, b);
  return;
}
bool is_prime(int a) {
  if (a == 2) return true;
  if (!(a & 1) || a == 1) return false;
  for (int i = 3; i * i <= a; i += 2)
    if (!(a % i)) return false;
  return true;
}
bool is_prime(long long a) {
  if (a == 2) return true;
  if (!(a & 1) || a == 1) return false;
  for (long long i = 3; i * i <= a; i += 2)
    if (!(a % i)) return false;
  return true;
}
bool is_palindrome(string s) {
  int len = (int)s.length();
  int mid = len >> 1;
  for (int i = 0; i < mid; i++)
    if (s[i] != s[len - i - 1]) return false;
  return true;
}
int gcd(int a, int b) {
  while (b) {
    int mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int binpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
int binpow(int a, int b, int MODULO) {
  int res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= MODULO;
    }
    a *= a;
    a %= MODULO;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  while (b) {
    long long mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
long long binpow(long long a, long long b, long long MODULO) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= MODULO;
    }
    a *= a;
    a %= MODULO;
    b >>= 1;
  }
  return res;
}
string binary(int N) {
  if (!N) return "0";
  string bin = "";
  while (N) {
    bin += '0' + (N & 1);
    N >>= 1;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
string binary(long long N) {
  if (!N) return "0";
  string bin = "";
  while (N) {
    bin += '0' + (N & 1);
    N >>= 1;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
const int INF = 2147483547;
const int MODULO = 1000000007;
const int _MODULO = 998244353;
const long long INF64 = 9223372036854775707;
const long long MODULO64 = 1000000007;
const long long _MODULO64 = 998244353;
const double epsilon = 10e-6;
const double PI = acos(-1);
int num = 100000;
vector<int> c, ans;
vector<vector<pair<int, int>>> dfs;
vector<vector<int>> tree;
void DFS(int u, int parent) {
  for (int v : tree[u]) {
    if (v == parent) continue;
    DFS(v, u);
  }
  if (!tree[u].size()) {
    if (c[u]) {
      cout << "NO" << '\n';
      exit(0);
    }
    ans[u] = num;
    dfs[u].emplace_back(num, u);
    dfs[parent].emplace_back(num, u);
    num += 100000;
    return;
  }
  if (c[u] > dfs[u].size()) {
    cout << "NO" << '\n';
    exit(0);
  }
  sort((dfs[u]).begin(), (dfs[u]).end());
  if (!c[u])
    ans[u] = dfs[u][0].first - 1;
  else
    ans[u] = dfs[u][c[u] - 1].first + 1;
  if (c[u] != dfs[u].size() && c[u]) {
    if (dfs[u][c[u]].first == ans[u]) {
      for (int i = c[u]; i < (int)dfs[u].size(); ++i) {
        ++dfs[u][i].first;
        ++ans[dfs[u][i].second];
      }
    }
  }
  dfs[u].insert(dfs[u].begin() + c[u], make_pair(ans[u], u));
  for (auto z : dfs[u]) dfs[parent].push_back(z);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  c.resize(n);
  ans.resize(n);
  dfs.resize(n);
  tree.resize(n);
  int root;
  for (int u = 0; u < n; ++u) {
    int p;
    cin >> p >> c[u];
    if (!p) {
      root = u;
      continue;
    }
    tree[--p].push_back(u);
  }
  DFS(root, root);
  cout << "YES" << '\n';
  for (int p : ans) cout << p << ' ';
  cout << '\n';
  return 0;
}
