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.util.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.io.*;
import java.math.*;
import java.text.DecimalFormat;
public class Prac{     
    static class InputReader { 
        private final InputStream stream;
	private final byte[] buf = new byte[8192];
	private int curChar, snumChars;
 	public InputReader(InputStream st) {
            this.stream = st;
	} 
	public int read() {
            if (snumChars == -1)
	 	throw new InputMismatchException();
            if (curChar >= snumChars) {
		curChar = 0;
                try {
                    snumChars = stream.read(buf);
		} 
                catch (IOException e) {
                    throw new InputMismatchException();
           	}
		if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
	}
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
               	c = read();
            }
            int sgn = 1;
            if (c == '-') {
		sgn = -1;
		c = read();
            }
            int res = 0;
            do {
		res *= 10;
		res += c - '0';
		c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
	} 
	public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
	} 
	public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
		a[i] = ni();
            }
            return a;
	} 
	public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
		c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
		res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
	}
	public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
		c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        } 
	public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
 
	private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
	} 
    }
    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L;
    static class Pair{
        int r,c;
        public Pair(int r,int c){
            this.c=c;
            this.r=r;
        }
    }
    static ArrayList<Integer> arr[];
    static int c[],ans[];
    static boolean v[],f;
    static TreeSet<Integer> set;
    static void dfs(int i,int p){
        int co=c[i]+1;
        for(int j:set){
            ans[i]=j;
            co--;
            if(co==0)break;
        }   
        set.remove(ans[i]);
        for(int j:arr[i]){
            if(j!=p)dfs(j,i);
        }
    }
    static int check(int i,int p){
        int co=0;
        for(int j:arr[i]){
            if(j!=p){
                co+=check(j,i);
            }
        }
        if(c[i]>co)f=true;
        return 1+co;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);	 
        int n=sc.ni();
        v=new boolean[n+1];
        arr=new ArrayList[n+1];
        ans=new int[n+1];
        c=new int[n+1];
        set=new TreeSet<>();
        for(int i=1;i<=n;i++){
            arr[i]=new ArrayList<>();
            set.add(i);
        }
        int root=-1;
        for(int i=1;i<=n;i++){
            int u=sc.ni();
            if(u==0){
                root=i;
                c[i]=sc.ni();
                continue;
            }
            arr[u].add(i);
            c[i]=sc.ni();
        }
        check(root,-1);
        if(f){
            w.println("NO");
        }
        else{
            v=new boolean[n+1];
            dfs(root,-1);
            w.println("YES");
            for(int i=1;i<=n;i++)w.print(ans[i]+" ");
            w.println();
            
        }
        w.close();
    }
}