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>
long long mod = 1000000007;
long long mod2 = 998244353;
long long OO = 1e18;
long long david_villa_pow(long long x, long long n) {
  if (n == 0) return 1;
  long long u = david_villa_pow(x, n / 2);
  u = ((u) * (u));
  if (n % 2 == 1) u = ((u) * (x));
  return u;
}
long long up(long long x, long long y) {
  if (x % y == 0) return x / y;
  return x / y + 1;
}
using namespace std;
long long n;
long long c[3000];
vector<long long> v[3000];
long long res[3000];
long long sub[3000];
long long vis[3000];
long long vis2[3000];
long long ST[3000];
bool ans = 1;
long long root;
long long dfs(long long node) {
  vis[node] = 1;
  long long x = 0;
  for (long long i = 0; i < v[node].size(); i++)
    if (!vis[v[node][i]]) x += dfs(v[node][i]);
  sub[node] = x;
  if (c[node] > sub[node]) ans = 0;
  return sub[node] + 1;
}
void El_MaraVilla(long long node) {
  vis[node] = 1;
  long long A = 0;
  for (long long i = 1; i <= n; i++) {
    if (A == c[node] && !vis2[i]) {
      res[node] = i;
      break;
    }
    if (!vis2[i]) A++;
  }
  vis2[res[node]] = 1;
  for (long long i = 0; i < v[node].size(); i++) {
    if (!vis[v[node][i]]) El_MaraVilla(v[node][i]);
  }
}
int main() {
  long long i, j;
  ;
  long long x;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> c[i];
    if (x == 0) {
      root = i;
      continue;
    }
    v[x].push_back(i);
    v[i].push_back(x);
  }
  dfs(root);
  ST[0] = 1;
  for (i = 1; i < v[root].size(); i++)
    ST[i] = ST[i - 1] + sub[v[root][i - 1]] + 1;
  memset(vis, 0, sizeof vis);
  El_MaraVilla(root);
  if (!ans)
    cout << "NO";
  else {
    cout << "YES" << endl;
    for (i = 1; i <= n; i++) cout << res[i] << " ";
  }
  return 0;
}
