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;
template <typename T, size_t N>
int size(const T (&t)[N]) {
  return N;
}
template <typename T>
int size(const T &t) {
  return t.size();
}
string to_string(const string s, int x1 = 0, int x2 = 1e9) {
  return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"';
}
string to_string(const char *s) { return to_string((string)s); }
string to_string(const bool b) { return (b ? "true" : "false"); }
string to_string(const char c) { return string({c}); }
template <size_t N>
string to_string(const bitset<N> &b, int x1 = 0, int x2 = 1e9) {
  string t = "";
  for (int __iii__ = min(x1, size(b)), __jjj__ = min(x2, size(b) - 1);
       __iii__ <= __jjj__; ++__iii__) {
    t += b[__iii__] + '0';
  }
  return '"' + t + '"';
}
template <typename A, typename... C>
string to_string(const A(&v), int x1 = 0, int x2 = 1e9, C... coords);
int l_v_l_v_l = 0, t_a_b_s = 0;
template <typename A, typename B>
string to_string(const pair<A, B> &p) {
  l_v_l_v_l++;
  string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
  l_v_l_v_l--;
  return res;
}
template <typename A, typename... C>
string to_string(const A(&v), int x1, int x2, C... coords) {
  int rnk = rank<A>::value;
  string tab(t_a_b_s, ' ');
  string res = "";
  bool first = true;
  if (l_v_l_v_l == 0) res += '\n';
  res += tab + "[";
  x1 = min(x1, size(v)), x2 = min(x2, size(v));
  auto l = begin(v);
  advance(l, x1);
  auto r = l;
  advance(r, (x2 - x1) + (x2 < size(v)));
  for (auto e = l; e != r; e = next(e)) {
    if (!first) {
      res += ", ";
    }
    first = false;
    l_v_l_v_l++;
    if (e != l) {
      if (rnk > 1) {
        res += '\n';
        t_a_b_s = l_v_l_v_l;
      };
    } else {
      t_a_b_s = 0;
    }
    res += to_string(*e, coords...);
    l_v_l_v_l--;
  }
  res += "]";
  if (l_v_l_v_l == 0) res += '\n';
  return res;
}
template <typename A, size_t N>
string to_string(const A (&v)[N], int x2) {
  return to_string(v, 0, x2);
}
void dbgm() { ; }
template <typename Heads, typename... Tails>
void dbgm(Heads H, Tails... T) {
  cout << to_string(H) << " | ";
  dbgm(T...);
}
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const double EPS = 1e-9;
const int MAX_N = 2005;
int parent[MAX_N], c[MAX_N], a[MAX_N];
vector<int> children[MAX_N], subtree[MAX_N];
int unlock[MAX_N];
vector<int> dfs(int u) {
  subtree[u].push_back(u);
  for (int v : children[u]) {
    vector<int> cur = dfs(v);
    for (int x : cur) {
      subtree[u].push_back(x);
    }
  }
  return subtree[u];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p, ci;
    cin >> p >> ci;
    parent[i] = p;
    c[i] = ci;
    children[p].push_back(i);
  }
  dfs(0);
  vector<int> bfs;
  for (int i = 1; i <= n; i++) {
    if (size(children[i]) == 0) bfs.push_back(i);
  }
  int ct = 1;
  bool works = true;
  while (size(bfs) > 0) {
    vector<int> temp;
    for (int u : bfs) {
      if (u == 0) break;
      vector<int> st;
      for (int v : subtree[u]) {
        if (u != v) st.push_back(a[v]);
      }
      sort(st.begin(), st.end());
      if (c[u] > size(st)) {
        works = false;
        break;
      } else if (c[u] == size(st)) {
        a[u] = ct++;
      } else {
        a[u] = st[c[u]];
        for (int v : subtree[u]) {
          if (u == v) continue;
          if (a[v] >= a[u]) a[v] += 2000;
        }
        ct += 2000;
      }
      int p = parent[u];
      unlock[p]++;
      if (unlock[p] == size(children[p])) {
        temp.push_back(p);
      }
    }
    if (!works) break;
    bfs = temp;
  }
  if (works) {
    cout << "YES\n";
    set<int> st;
    for (int i = 1; i <= n; i++) {
      cout << a[i] << ' ';
      assert(!st.count(a[i]));
      st.insert(a[i]);
    }
  } else {
    cout << "NO\n";
  }
  return 0;
}
