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.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.AbstractCollection;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.LinkedList;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Mufaddal Naya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DNumbersOnTree solver = new DNumbersOnTree();
        solver.solve(1, in, out);
        out.close();
    }

    static class DNumbersOnTree {
        int[] tt;
        ArrayList<iip> ss;

        public void solve(int testNumber, InputReader c, OutputWriter w) {
            int n = c.readInt();
            ArrayList<Integer> adj[] = new ArrayList[n];
            int a[] = new int[n];
            tt = new int[n];
            for (int i = 0; i < n; i++) {
                adj[i] = new ArrayList<>();
            }
            int root = -1;
            for (int i = 0; i < n; i++) {
                int u = c.readInt() - 1;
                a[i] = c.readInt();
                if (u == -1) {
                    root = i;
                } else {
                    adj[u].add(i);
                }
            }
            TreeSet<iip> ts = new TreeSet<>();

            LinkedList<iip> q = new LinkedList<>();
            q.add(new iip(0, root));
            while (!q.isEmpty()) {
                iip pp = q.pollFirst();
                ts.add(pp);
                for (int x : adj[pp.b]) {
                    q.add(new iip(pp.a + 1, x));
                }
            }
//        w.printLine(ts);

//        Arrays.fill(tt,-1);
            boolean isp = true;
            while (!ts.isEmpty()) {
                iip pp = ts.pollLast();
                ss = new ArrayList<>();
                solve_(pp.b, adj);
                Collections.sort(ss);
                if (ss.size() < a[pp.b] + 1) {
                    isp = false;
                    break;
                }
                for (int i = a[pp.b] + 1; i < ss.size(); i++) {
                    tt[ss.get(i).b] += 2;
                }
                tt[pp.b] = ss.get(a[pp.b]).a + 1;
            }
            if (isp) {
                w.printLine("YES");
                w.printLine(tt);
            } else {
                w.printLine("NO");
            }
        }

        private void solve_(int x, ArrayList<Integer>[] adj) {

            ss.add(new iip(tt[x], x));
            for (int xtr : adj[x]) {
                solve_(xtr, adj);
            }
        }

    }

    static class iip implements Comparable<iip> {
        int a;
        int b;

        public iip(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public int compareTo(iip o) {
            if (this.a == o.a) {
                return this.b - o.b;
            }
            return this.a - o.a;
        }

        public String toString() {
            return "iip{" +
                    "a=" + a +
                    ", b=" + b +
                    '}';
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void print(int[] array) {
            for (int i = 0; i < array.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(array[i]);
            }
        }

        public void printLine(int[] array) {
            print(array);
            writer.println();
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

        public 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++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

