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.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.io.InputStream;

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

    static class DNumbersOnTree {
        ArrayList<Integer>[] arrayList;
        int[] c;
        int root;
        boolean ans;

        int[] dfs(int node) {
            ArrayList<Integer> list = new ArrayList<>();
            for (int k : arrayList[node]) {
                int[] temp = dfs(k);
                if (temp == null) return null;
                for (int p : temp) list.add(p);
            }


            if (list.size() < c[node]) {
                ans = false;
                return null;
            } else {
                int aa[] = new int[list.size() + 1];
                int p = 0;
                for (int i = 0; i < aa.length; i++) {
                    if (i == c[node]) {
                        aa[i] = node;
                    } else {
                        aa[i] = list.get(p++);
                    }
                }
                return aa;
            }
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            arrayList = new ArrayList[n + 1];
            c = new int[n + 1];
            root = -1;
            ans = true;
            for (int i = 0; i <= n; i++) arrayList[i] = new ArrayList<>();
            for (int i = 1; i <= n; i++) {
                int p = in.scanInt();
                c[i] = in.scanInt();
                if (p == 0) {
                    root = i;
                } else {
                    arrayList[p].add(i);
                }
            }

            int order[] = dfs(root);

            if (!ans) {
                out.println("NO");
                return;
            }


            int res[] = new int[n + 1];
            for (int i = 0; i < order.length; i++) res[order[i]] = i + 1;
            out.println("YES");
            for (int i = 1; i <= n; i++) out.print(res[i] + " ");


        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}

