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
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class TaskD {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    int n = Integer.parseInt(br.readLine());
    int[] p = new int[n];
    int[] greater = new int[n];
    Node[] nodes = new Node[n];
    for (int i=0; i<n; i++) {
      nodes[i] = new Node(i);
    }
    for (int i=0; i<n; i++) {
      String[] s = br.readLine().split(" ");
      int parent = Integer.parseInt(s[0])-1;
      int c = Integer.parseInt(s[1]);
      p[i] = parent;
      greater[i] = c;
      nodes[i].p = parent;
      nodes[i].g = c;
      if (parent>=0) {
        nodes[parent].children.add(i);
      }
    }
    PriorityQueue<Pair> pq = new PriorityQueue<>();
    int[] degs = new int[n];
    for (int i=0; i<n; i++) {
      degs[i] = nodes[i].children.size();
      pq.offer(new Pair(i, degs[i]));
    }
    while (pq.size() > 0) {
      Pair curr = pq.poll();
      if (curr.deg!=degs[curr.id]) {
        continue;
      }
      ArrayList<Integer> order = new ArrayList<>();
      for (int child: nodes[curr.id].children) {
        for (int id: nodes[child].order) {
          order.add(id);
        }
      }
      if (greater[curr.id]>order.size()) {
        System.out.println("NO");
        return;
      }
      order.add(greater[curr.id], curr.id);
      nodes[curr.id].order = order;
      /*
      System.out.println(curr.id);
      for (int i=0; i<order.size(); i++) {
        System.out.println("\t"+order.get(i));
      }
      */
      int parent = nodes[curr.id].p;
      if (parent>=0) {
        degs[parent]--;
        pq.offer(new Pair(parent, degs[parent]));
      }
    }
    int[] sol = new int[n];
    ArrayList<Integer> finalOrder = new ArrayList<Integer>();
    for (int i=0; i<n; i++) {
      if (nodes[i].p==-1) {
        finalOrder = nodes[i].order;
        break;
      }
    }
    for (int i=0; i<n; i++) {
      sol[finalOrder.get(i)] = i+1;
    }
    System.out.println("YES");
    for (int i=0; i<n; i++) {
      sb.append(sol[i]);
      sb.append(i== n-1 ? '\n' : ' ');
    }
    System.out.print(sb);
  }
}
class Pair implements Comparable<Pair> {
  int id;
  int deg;
  public Pair(int idd, int degg) {
    id = idd;
    deg = degg;
  }
  public int compareTo(Pair p2) {
    return deg - p2.deg;
  }
}
class Node {
  int id;
  int p;
  int g;
  ArrayList<Integer> children;
  ArrayList<Integer> order;
  public Node(int idd) {
    id = idd;
    p = -1;
    children = new ArrayList<>();
    order = new ArrayList<>();
  }
}
