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.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;


import java.util.Random;
import java.util.TreeSet;

public final class CF_612_D2_D
{


	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputFlush(Object o){try {out.write(""+ o+"\n");out.flush();} catch (Exception e) {}}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}



	// Global vars
	static BufferedWriter out;
	static InputReader reader;



	static void test() {
		log("testing");

		Random r=new Random();
		int NTESTS=100000;
		int NMAX=10;
		for (int t=0;t<NTESTS;t++) {
		}

		log("done");

	}

	static class Composite implements Comparable<Composite> {

		int idx;
		int w;

		public int compareTo(Composite X) {
			if (w!=X.w)
				return w-X.w;
			return idx-X.idx;
		}

		public Composite(int idx, int w) {
			this.idx = idx;
			this.w = w;
		}

		public String toString() {
			return (idx+1)+":"+w;
		}


	}

	
	
	static void computeSub(int node) {
		//log("comput sub:"+node);
		for (int v:friends[node]) {
			computeSub(v);
			sub[node]+=sub[v];
		}
		sub[node]++;
		
	}
	
	static int idx;
	

	// return highest
	// we keep all the elements different
	
	static int st;
	static int[] stack;
	
	static void populate(int u) {
		
		for (int v:friends[u])
			populate(v);
		stack[st++]=ar[u];
	}
	
	
	static void adjust(int u,int val) {
		for (int v:friends[u])
			adjust(v,val);
		if (ar[u]>val)
			ar[u]++;
	}
	
	static int explore(int u,int base) {
		//log("==== exploring :"+(u+1));
		int ref=base;
		if (below[u]==0)
			base++;
		if (below[u]>sub[u]-1)
			return -1;
		
		if (sub[u]==1) {
			ar[u]=base;
			//log("explore:"+(u+1)+" returning:"+base);
			return base;
		}
		
		
		for (int v:friends[u]) {
			int ans=explore(v,base);
			if (ans==-1) {
				log("problem");
				return -1;
			}
			
			base=ans+1;
		}
	
		st=0;
		
		populate(u);
		
		Arrays.parallelSort(stack,0,sub[u]-1);
		if (below[u]>0) {
			int thre=stack[below[u]-1];
			//log(ar);
			//log("u:"+(u+1)+" thre:"+thre);
			adjust(u,thre);
			ar[u]=thre+1;
			base++;
		} else {
			ar[u]=ref;
		}
		
		// now take the below lower, decrease them, and put 
		
		
		//log("explore:"+(u+1)+" returning:"+base);
		return base;
	}
	
	
	static ArrayList<Integer>[] friends;
	static int[] anc;
	static int[] sub;
	static int[] below;
	static int[] ar;
	static int[] min;
	static int[] max;
	
	static void process() throws Exception {

		//log("hello");

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);

		int n=reader.readInt();
		
		stack=new int[n];
		
		anc=new int[n];
		friends=new ArrayList[n];
		for (int u=0;u<n;u++)
			friends[u]=new ArrayList<Integer>();
		below=new int[n];
		int root=0;
		for (int u=0;u<n;u++) {
			int v=reader.readInt()-1;
			anc[u]=v;
			if (v>=0)
				friends[v].add(u);
			below[u]=reader.readInt();
			if (anc[u]==-1)
				root=u;
		}
		//for (int u=0;u<n;u++)
		//	log(friends[u]);
		
		sub=new int[n];
		ar=new int[n];
		min=new int[n];
		max=new int[n];
		Arrays.fill(min, Integer.MAX_VALUE);
		Arrays.fill(max, Integer.MIN_VALUE);
		computeSub(root);
		//log(sub);
		idx=0;
		int res=explore(root,1);
		if (res<0) {
			output("NO");
		} else {
			output("YES");
			
			for (int i=0;i<n;i++) {
				outputWln(ar[i]+" ");
			}
			output("");
		}
		
		try {
			out.close();
		} catch (Exception Ex) {
		}

	}





	public static void main(String[] args) throws Exception {
		process();

	}

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

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

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final String readString(int L) throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder(L);
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

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

}
/*

5
1 4 5 2 3

 */