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.*;
import java.util.*;

public class B {

	static ArrayList<Integer>[] adj;
	static int[] sub, level;

	static ArrayList<Integer> subtree;

	static void dfs(int u, int p, int d) {
		sub[u] = 1;
		level[u] = d;
		for (int v : adj[u])
			if (v != p) {
				dfs(v, u, d + 1);
				sub[u] += sub[v];
			}
	}

	static void dfs2(int u, boolean start) {
		if (!start)
			subtree.add(u);
		for (int v : adj[u])
			if (level[v] > level[u])
				dfs2(v, false);
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), root = -1;
		subtree = new ArrayList();
		adj = new ArrayList[n];
		for (int i = 0; i < n; i++)
			adj[i] = new ArrayList();
		int[] c = new int[n];
		sub = new int[n];
		level = new int[n];
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt() - 1;
			c[i] = sc.nextInt();
			if (p != -1) {
				adj[p].add(i);
			} else
				root = i;

		}
		dfs(root, root, 0);
		Integer[] nodes = new Integer[n];
		for (int i = 0; i < n; i++)
			nodes[i] = i;
		int[] ans = new int[n];
		int curr = 1;
		for (int i = 0; i < n; i++)
			if (adj[i].size() == 0) {
				ans[i] = curr++;
				if (c[i] != 0) {
					System.out.println("NO");
					return;
				}
			}
		Arrays.sort(nodes, (x, y) -> level[y] - level[x]);

		for (int node : nodes) {
//			System.out.println(level[node]);
			if (adj[node].size() == 0)
				continue;
			subtree.clear();
			dfs2(node, true);
			Collections.sort(subtree, (x, y) -> ans[x] - ans[y]);
			if (c[node] >= sub[node]) {
				System.out.println("NO");
				return;
			}
			if (c[node] == 0)
				ans[node] = 1;
			else {
				ans[node] = ans[subtree.get(c[node] - 1)] + 1;

			}
			for (int x : subtree)
				if (ans[x] >= ans[node])
					ans[x]++;
			Integer[] tmp = nodes.clone();
			Arrays.sort(tmp, (x, y) -> ans[x] - ans[y]);
			curr = 1;
			for (int u : tmp)
				ans[u] = curr++;

		}
		out.println("YES");
		for (int x : ans)
			out.print(x + " ");

		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}