#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int Mod = 1e9 + 7;
const int N = 2e3 + 100;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
inline long long dpow(long long a, long long b) {
  long long r = 1, t = a;
  while (b) {
    if (b & 1) r = (r * t) % Mod;
    b >>= 1;
    t = (t * t) % Mod;
  }
  return r;
}
inline long long fpow(long long a, long long b) {
  long long r = 1, t = a;
  while (b) {
    if (b & 1) r = (r * t);
    b >>= 1;
    t = (t * t);
  }
  return r;
}
vector<int> G[N], vec;
int a[N], sz[N], n;
int ans[N];
void DFS(int x) {
  sz[x] = 1;
  for (auto v : G[x]) {
    DFS(v);
    sz[x] += sz[v];
  }
  if (sz[x] - 1 < a[x]) puts("NO"), exit(0);
}
void DFS1(int x) {
  ans[x] = vec[a[x] + 1];
  vec.erase(vec.begin() + a[x] + 1);
  for (auto v : G[x]) DFS1(v);
}
int main() {
  cin >> n;
  vec.push_back(0);
  int rt = 1;
  for (int i = 1; i <= n; i++) {
    int u;
    scanf("%d %d", &u, &a[i]);
    if (u)
      G[u].push_back(i);
    else
      rt = i;
    vec.push_back(i);
  }
  DFS(rt);
  DFS1(rt);
  puts("YES");
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
