Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its vertices also has an integer a_i written on it. For each vertex i, Evlampiy calculated c_i — the number of vertices j in the subtree of vertex i, such that a_j < a_i. 

<image>Illustration for the second example, the first integer is a_i and the integer in parentheses is c_i

After the new year, Evlampiy could not remember what his gift was! He remembers the tree and the values of c_i, but he completely forgot which integers a_i were written on the vertices.

Help him to restore initial integers!

Input

The first line contains an integer n (1 ≤ n ≤ 2000) — the number of vertices in the tree.

The next n lines contain descriptions of vertices: the i-th line contains two integers p_i and c_i (0 ≤ p_i ≤ n; 0 ≤ c_i ≤ n-1), where p_i is the parent of vertex i or 0 if vertex i is root, and c_i is the number of vertices j in the subtree of vertex i, such that a_j < a_i.

It is guaranteed that the values of p_i describe a rooted tree with n vertices.

Output

If a solution exists, in the first line print "YES", and in the second line output n integers a_i (1 ≤ a_i ≤ {10}^{9}). If there are several solutions, output any of them. One can prove that if there is a solution, then there is also a solution in which all a_i are between 1 and 10^9.

If there are no solutions, print "NO".

Examples

Input


3
2 0
0 2
2 0


Output


YES
1 2 1 

Input


5
0 1
1 3
2 1
3 0
2 0


Output


YES
2 3 2 1 2
#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
const long long inf = 2147383647;
const long long mod = 1000000007;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
int n;
int child[2002], par[2002], smol[2002], val[2002];
vector<int> v[2002];
vector<pair<int, int> > nvec[2002];
void addNum(int node, int toAdd) {
  for (int i = 0; i < ((long long)(nvec[node]).size()); i++) {
    nvec[node][i].first += toAdd;
    val[nvec[node][i].second] = nvec[node][i].first;
  }
}
int getMax(int node) {
  int res = nvec[node][((long long)(nvec[node]).size()) - 1].first;
  return res;
}
void dfs(int node) {
  if (!((long long)(v[node]).size())) {
    val[node] = 1;
    nvec[node].clear();
    nvec[node].push_back(make_pair(1, node));
    return;
  }
  int x, y;
  for (int i = 0; i < ((long long)(v[node]).size()); i++) {
    x = v[node][i];
    dfs(x);
  }
  for (int i = 0; i < ((long long)(v[node]).size()) - 1; i++) {
    x = getMax(v[node][i]);
    addNum(v[node][i + 1], x);
  }
  int cnt = smol[node], prev = 0;
  nvec[node].clear();
  for (int i = 0; i < ((long long)(v[node]).size()); i++) {
    x = v[node][i];
    for (int j = 0; j < ((long long)(nvec[x]).size()); j++) {
      if (!cnt) {
        nvec[node].push_back(make_pair(prev + 1, node));
        val[node] = prev + 1;
      }
      if (cnt <= 0) {
        nvec[node].push_back(nvec[x][j]);
        nvec[node][((long long)(nvec[node]).size()) - 1].first += 1;
        val[nvec[node][((long long)(nvec[node]).size()) - 1].second] =
            nvec[node][((long long)(nvec[node]).size()) - 1].first;
      } else {
        nvec[node].push_back(nvec[x][j]);
      }
      prev = nvec[x][j].first;
      cnt--;
    }
  }
  if (!cnt) {
    nvec[node].push_back(make_pair(prev + 1, node));
    val[node] = prev + 1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int root, x, y;
  cin >> n;
  for (long long i = (1); i <= (n); ++i) {
    cin >> par[i] >> smol[i];
    if (!par[i]) {
      root = i;
      continue;
    }
    v[par[i]].push_back(i);
  }
  for (long long i = (1); i <= (n); ++i) {
    x = par[i];
    while (x) {
      child[x]++;
      x = par[x];
    }
  }
  for (long long i = (1); i <= (n); ++i) {
    if (smol[i] > child[i]) {
      cout << "NO"
           << "\n";
      return 0;
    }
  }
  dfs(root);
  cout << "YES"
       << "\n";
  for (long long i = (1); i <= (n); ++i) {
    cout << val[i] << " ";
  }
  cout << "\n";
  return 0;
}
