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;
int n;
vector<int> save[2010];
int ji[2010];
int xia[2010];
int l;
int root;
struct node {
  int index;
  int zhi;
};
vector<node> xx[2010];
int fl = 1;
void dfs(int x) {
  xia[x] = 0;
  for (int i = 0; i < save[x].size(); i++) {
    dfs(save[x][i]);
    xia[x] = xia[x] + xia[save[x][i]] + 1;
  }
  if (xia[x] < ji[x]) {
    fl = 0;
  }
}
int te = 100000000;
int shu = 1;
int ans[2010];
int k = 600000;
int zhi;
vector<int> su;
bool cmp(node a, node b) { return a.zhi < b.zhi; }
void dfs2(int x) {
  zhi--;
  if (save[x].size() == 0) {
    ans[x] = te;
    te = te + 100000;
    return;
  }
  k--;
  for (int i = 0; i < save[x].size(); i++) {
    dfs2(save[x][i]);
    for (int j = 0; j < xx[save[x][i]].size(); j++) {
      xx[x].push_back({xx[save[x][i]][j].index, xx[save[x][i]][j].zhi});
    }
    xx[x].push_back({save[x][i], ans[save[x][i]]});
  }
  sort(xx[x].begin(), xx[x].end(), cmp);
  if (ji[x] == 0) {
    ans[x] = xx[x][0].zhi - su[zhi];
  } else if (ji[x] == xia[x]) {
    ans[x] = xx[x][xx[x].size() - 1].zhi + su[zhi];
  } else {
    for (int i = 0; i < ji[x]; i++) {
      xx[x][i].zhi = xx[x][i].zhi - 3;
      ans[xx[x][i].index] = ans[xx[x][i].index] - 3;
    }
    for (int i = ji[x]; i < xx[x].size() - 1; i++) {
      xx[x][i].zhi = xx[x][i].zhi + 3;
      ans[xx[x][i].index] = ans[xx[x][i].index] + 3;
    }
    ans[x] = (xx[x][ji[x] - 1].zhi + xx[x][ji[x]].zhi) / 2;
  }
}
bool p(int j) {
  for (int i = 2; i * i <= j; i++) {
    if (j % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 10000; i <= 50000; i++) {
    if (p(i)) {
      su.push_back(i);
    }
  }
  zhi = su.size() - 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l, &ji[i]);
    if (l == 0) {
      root = i;
    } else {
      save[l].push_back(i);
    }
  }
  dfs(root);
  if (fl == 0) {
    cout << "NO";
    return 0;
  }
  dfs2(root);
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
}
