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.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;

public class test3
{
	static boolean poss;
	static class Reader 
    { 
        final private int BUFFER_SIZE = 1 << 16; 
        private DataInputStream din; 
        private byte[] buffer; 
        private int bufferPointer, bytesRead; 
  
        public Reader() 
        { 
            din = new DataInputStream(System.in); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public Reader(String file_name) throws IOException 
        { 
            din = new DataInputStream(new FileInputStream(file_name)); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public String readLine() throws IOException 
        { 
            byte[] buf = new byte[64]; // line length 
            int cnt = 0, c; 
            while ((c = read()) != -1) 
            { 
                if (c == '\n') 
                    break; 
                buf[cnt++] = (byte) c; 
            } 
            return new String(buf, 0, cnt); 
        } 
  
        public int nextInt() throws IOException 
        { 
            int ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do
            { 
                ret = ret * 10 + c - '0'; 
            }  while ((c = read()) >= '0' && c <= '9'); 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public long nextLong() throws IOException 
        { 
            long ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public double nextDouble() throws IOException 
        { 
            double ret = 0, div = 1; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
  
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
  
            if (c == '.') 
            { 
                while ((c = read()) >= '0' && c <= '9') 
                { 
                    ret += (c - '0') / (div *= 10); 
                } 
            } 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        private void fillBuffer() throws IOException 
        { 
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
            if (bytesRead == -1) 
                buffer[0] = -1; 
        } 
  
        private byte read() throws IOException 
        { 
            if (bufferPointer == bytesRead) 
                fillBuffer(); 
            return buffer[bufferPointer++]; 
        } 
  
        public void close() throws IOException 
        { 
            if (din == null) 
                return; 
            din.close(); 
        } 
    } 
	
	static int[] dfs(int n , LinkedList<Integer> arr[] , boolean visited[] , int dp[] , int c[])
	{
		visited[n] = true;
		
		
		if(arr[n].size() == 1 && visited[arr[n].get(0)])
		{
			int ans[] = new int[1];
			ans[0] = n;
			if(c[n] != 0)
				poss = false;
			dp[n] = 1;
			return ans;
		}
		
		ArrayList<Integer> temp = new ArrayList<Integer>();
		int sz = 0;
		for(Integer i : arr[n])
		{
			if(!visited[i])
			{
				int tt[] = dfs(i,arr,visited,dp,c);
				dp[n] += dp[i];
				for(int j = 0 ; j < tt.length ; j++)
				{
					temp.add(tt[j]);
				}
			}
		}
		dp[n]++;
		int ans[] = new int[temp.size()+1];
		for(int i = 0 ; i < temp.size();i++)
		{
			ans[i] = temp.get(i);
		}
		if(!poss || dp[n]-1 < c[n])
		{
		//System.out.println(dp[n] + " " + c[n]);
			poss = false;
			return ans;
		}
		
		else
		{
			if(c[n] == ans.length-1)
				ans[ans.length-1] = n;
			
			else
			{
			for(int i = ans.length-1 ; i > c[n] ; i--)
			{
				ans[i] = ans[i-1];
			}
			ans[c[n]] = n;
			}
			return ans;
		}
		
		
	}
	
	public static void main(String []args) throws IOException
	{
		Reader sc = new Reader();
		int n = sc.nextInt();
		int a[] = new int[n+1];
		
		LinkedList<Integer> arr[] = new LinkedList[n+1];
		for(int i = 1 ; i <= n ; i++)
		{
			arr[i] = new LinkedList<Integer>();
		}
		int root = -1;
		for(int i = 1 ; i <= n ; i++)
		{
			int p = sc.nextInt();
			int c = sc.nextInt();
			a[i] = c;
			if(p != 0)
			{
			arr[p].add(i);
			arr[i].add(p);
			}
			
			else
				root = i;
		}
		
		
		boolean visited[] = new boolean[n+1];
		int dp[] = new int[n+1];
		poss = true;
		int ans[] = dfs(root,arr,visited,dp,a);
		
		if(!poss)
			System.out.println("NO");
		
		else
		{
			int ans2[] = new int[n+1];
			System.out.println("YES");
			for(int i = 1 ; i <= n ; i++)
			{
				ans2[ans[i-1]] = i;
			}
			
			StringBuffer str = new StringBuffer("");
			for(int i = 1 ; i <= n ; i++)
			{
				str.append(ans2[i] + " ");
			}
			System.out.println(str);
		
		}
	}
}