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;
long long INF = LLONG_MAX;
const long long M = 1000000007;
struct obj {
  long long x, y;
};
long long powm(long long, long long);
const int N = 3e0 + 5;
long long tree[4 * N + 1];
long long A[N];
long long lazy[4 * N + 1] = {0};
void build(long long, long long, long long);
void update(long long, long long, long long, long long, long long);
long long query(long long, long long, long long, long long, long long);
void updateRange(long long, long long, long long, long long, long long,
                 long long);
long long queryRange(long long, long long, long long, long long, long long);
vector<long long> tr[2005];
long long c[2005];
bool sahi = 1;
vector<long long> beer[2005];
bool vis[2005] = {0};
void dfs(long long ind) {
  bool che = 0;
  vis[ind] = 1;
  for (auto x : tr[ind]) {
    if (!vis[x]) {
      dfs(x);
      for (auto k : beer[x]) {
        if (beer[ind].size() == c[ind]) che = 1, beer[ind].push_back(ind);
        beer[ind].push_back(k);
        if (beer[ind].size() == c[ind]) che = 1, beer[ind].push_back(ind);
      }
    }
  }
  if (beer[ind].size() == 0) {
    beer[ind].push_back(ind);
    che = 1;
    if (c[ind]) sahi = 0;
  }
  if (!che)
    if (sahi) sahi = 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long root = INF;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    long long y;
    cin >> y;
    c[i + 1] = y;
    if (x == 0)
      root = i + 1;
    else {
      tr[x].push_back(i + 1);
      tr[i + 1].push_back(x);
    }
  }
  dfs(root);
  long long ans[n];
  for (int i = 0; i < n; i++) {
    ans[beer[root][i] - 1] = i + 1;
  }
  if (sahi) {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
  } else
    cout << "NO" << endl;
}
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % M;
    a = (a * a) % M;
    b >>= 1;
  }
  return res;
}
void build(long long node, long long start, long long end) {
  if (start == end) {
    tree[node] = A[start];
  } else {
    long long mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    tree[node] = tree[2 * node] + tree[2 * node + 1];
  }
}
void update(long long node, long long start, long long end, long long idx,
            long long val) {
  if (start == end) {
    A[idx] += val;
    tree[node] += val;
  } else {
    long long mid = (start + end) / 2;
    if (start <= idx and idx <= mid) {
      update(2 * node, start, mid, idx, val);
    } else {
      update(2 * node + 1, mid + 1, end, idx, val);
    }
    tree[node] = tree[2 * node] + tree[2 * node + 1];
  }
}
long long query(long long node, long long start, long long end, long long l,
                long long r) {
  if (r < start or end < l) {
    return 0;
  }
  if (l <= start and end <= r) {
    return tree[node];
  }
  long long mid = (start + end) / 2;
  long long p1 = query(2 * node, start, mid, l, r);
  long long p2 = query(2 * node + 1, mid + 1, end, l, r);
  return (p1 + p2);
}
void updateRange(long long node, long long start, long long end, long long l,
                 long long r, long long val) {
  if (lazy[node] != 0) {
    tree[node] += (end - start + 1) * lazy[node];
    if (start != end) {
      lazy[node * 2] += lazy[node];
      lazy[node * 2 + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start > end or start > r or end < l) return;
  if (start >= l and end <= r) {
    tree[node] += (end - start + 1) * val;
    if (start != end) {
      lazy[node * 2] += val;
      lazy[node * 2 + 1] += val;
    }
    return;
  }
  long long mid = (start + end) / 2;
  updateRange(node * 2, start, mid, l, r, val);
  updateRange(node * 2 + 1, mid + 1, end, l, r, val);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
}
long long queryRange(long long node, long long start, long long end,
                     long long l, long long r) {
  if (start > end or start > r or end < l) return 0;
  if (lazy[node] != 0) {
    tree[node] += (end - start + 1) * lazy[node];
    if (start != end) {
      lazy[node * 2] += lazy[node];
      lazy[node * 2 + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start >= l and end <= r) return tree[node];
  long long mid = (start + end) / 2;
  long long p1 = queryRange(node * 2, start, mid, l, r);
  long long p2 = queryRange(node * 2 + 1, mid + 1, end, l, r);
  return (p1 + p2);
}
