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
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.IntConsumer;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD(in, out);
        try {
            solver.solve();
        } catch (ExitException ignored) {
        }
        out.close();
    }

    static class TaskD {
        FastScanner sc;
        PrintWriter out;

        public TaskD(FastScanner sc, PrintWriter out) {
            this.sc = sc;
            this.out = out;
        }

        public void solve() {
            times(1, this::solve);
        }

        public void solve(int time) {
            int n = sc.nextInt();
            TaskD.Node[] nodes = new TaskD.Node[n];
            for (int i = 0; i < n; i++) nodes[i] = new TaskD.Node();

            TaskD.Node root = null;
            for (int i = 0; i < n; i++) {
                int parent = sc.nextInt();
                TaskD.Node node = nodes[i];
                if (parent == 0) {
                    root = node;
                } else {
                    nodes[parent - 1].children.add(node);
                }
                node.c = sc.nextInt();
            }

            dfsPower(root);
            List<Integer> set = new ArrayList<>(n);
            for (int i = 1; i <= n; i++) set.add(i);

            dfs(root, set);
            writeln("YES");
            for (TaskD.Node node : nodes) {
                write(node.a + " ");
            }
            writeln("");
        }

        private void dfsPower(TaskD.Node root) {
            root.power = 1;
            if (root.children.size() > 0) {
                for (TaskD.Node child : root.children) {
                    dfsPower(child);
                    root.power += child.power;
                }
            }
        }

        private void dfs(TaskD.Node root, List<Integer> set) {
            if (root.power <= root.c) answer("NO");

            root.a = set.remove(root.c);

            List<TaskD.Node> children = root.children;
            if (children.size() == 0) {
                return;
            } else if (children.size() == 1) {
                dfs(children.get(0), set);
            } else {
                int from = 0;
                for (TaskD.Node child : children) {
                    List<Integer> childSet = new ArrayList<>(child.power);
                    for (int i = 0; i < child.power; i++, from++) {
                        childSet.add(set.get(from));
                    }
                    dfs(child, childSet);
                }
            }
        }

        private void write(Object obj) {
            out.print(obj);
        }

        private void writeln(Object obj) {
            out.println(obj);
        }

        private void answer(Object ans) {
            out.println(ans);
            throw new ExitException();
        }

        private void times(int n, IntConsumer consumer) {
            for (int i = 0; i < n; i++) {
                try {
                    consumer.accept(i);
                } catch (ExitException ignored) {
                }
            }
        }

        static class Node {
            int a;
            int c;
            int power;
            List<TaskD.Node> children = new ArrayList<>();

            public String toString() {
                return "Node{" + c + ", " + children + '}';
            }

        }

    }

    static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

    }

    static class ExitException extends RuntimeException {
    }
}

