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>
struct MI {
 private:
  char bb[1 << 14];
  FILE* f;
  char *bs, *be;
  char e;
  bool o, l;

 public:
  MI() : f(stdin), bs(0), be(0) {}
  MI(FILE* f) : f(f), bs(0), be(0) {}
  inline operator bool() { return !l; }
  inline char get() {
    if (o) {
      o = 0;
      return e;
    }
    if (bs == be) be = (bs = bb) + fread(bb, 1, sizeof(bb), f);
    if (bs == be) {
      l = 1;
      return -1;
    };
    return *bs++;
  }
  inline void unget(char c) {
    o = 1;
    e = c;
  }
  template <class T>
  inline T read() {
    T r;
    *this > r;
    return r;
  }
  template <class T>
  inline MI& operator>(T&);
};
template <class T>
struct Q {
  const static bool U = T(-1) >= T(0);
  inline void operator()(MI& t, T& r) const {
    r = 0;
    char c;
    bool y = 0;
    if (U)
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (isdigit(c)) break;
      }
    else
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (c == '-') {
          c = t.get();
          if (isdigit(c)) {
            y = 1;
            break;
          };
        } else if (isdigit(c))
          break;
        ;
      };
    for (;;) {
      if (c == -1) goto E;
      if (isdigit(c))
        r = r * 10 + (c ^ 48);
      else
        break;
      c = t.get();
    }
    t.unget(c);
  E:;
    if (y) r = -r;
  }
};
template <>
struct Q<char> {
  inline void operator()(MI& t, char& r) {
    int c;
    for (;;) {
      c = t.get();
      if (c == -1) {
        r = -1;
        return;
      };
      if (!isspace(c)) {
        r = c;
        return;
      };
    }
  }
};
template <class T>
inline MI& MI::operator>(T& t) {
  Q<T>()(*this, t);
  return *this;
}
template <class T>
std::ostream& operator<(std::ostream& out, const T& t) {
  return out << t;
}
using std::cout;
MI cin;
const int $n = 2005;
int n, fa[$n], v[$n], deg[$n], rt, ans[$n], siz[$n], dep[$n], tp;
std::vector<int> outs[$n];
struct cmp_t {
  inline bool operator()(int x, int y) const { return dep[x] > dep[y]; }
};
std::priority_queue<int, std::vector<int>, cmp_t> q;
void dfs(int x) {
  siz[x] = 1;
  dep[x] = dep[fa[x]] + 1;
  for (int v : outs[x]) dfs(v), siz[x] += siz[v];
}
int main() {
  cin > n;
  for (int __r = (n), i = (1); i <= __r; ++i) {
    cin > fa[i] > v[i];
    if (!fa[i]) rt = i;
    outs[fa[i]].push_back(i);
    ++deg[fa[i]];
  }
  dfs(rt);
  for (int __r = (n), i = (1); i <= __r; ++i)
    if (v[i] >= siz[i]) return cout < "NO\n", 0;
  for (int __r = (n), i = (1); i <= __r; ++i)
    if (!v[i]) q.push(i);
  while (!q.empty()) {
    const auto x = q.top();
    q.pop();
    ans[x] = ++tp;
    for (int i = fa[x]; i; i = fa[i])
      if (!--v[i]) q.push(i);
  }
  for (int __r = (n), i = (1); i <= __r; ++i)
    if (!ans[i]) return cout < "NO\n", 0;
  cout < "YES\n";
  for (int __r = (n), i = (1); i <= __r; ++i) cout < ans[i] < " \n"[i == n];
}
