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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;

public class Main implements Runnable {

	int id[];
	List<Integer> edges[];
	long tree[];
	int c[];
	int sz[];
	int ans[];

	void pre(int s) {
		sz[s] = 1;
		for (int x : edges[s]) {
			pre(x);
			sz[s] += sz[x];
		}
	}

	void dfs(int s, ArrayDeque<Integer> child) {
		int t = 0;
		int ele = 0;
		for (int x : child) {
			if (t == c[s])
				ele = x;
			++t;
		}
		ans[s] = ele;
		child.remove(ele);
//		System.err.println(child);
		for (int x : edges[s]) {
			ArrayDeque<Integer> tmp = new ArrayDeque<>();
			for (int i = 0; i < sz[x]; ++i) {
				tmp.addFirst(child.getLast());
				child.pollLast();
			}
			dfs(x, tmp);
		}
	}

	private void solve() throws IOException {
		int n = nextInt();
		c = new int[n];
		edges = new ArrayList[n];
		ans = new int[n];
		Arrays.setAll(edges, i -> new ArrayList<>());
		int ind = -1;
		for (int i = 0; i < n; ++i) {
			int p = nextInt();
			c[i] = nextInt();
			--p;
			if (p == -1) {
				ind = i;
			} else {
				edges[p].add(i);
			}
		}
		sz = new int[n];
		pre(ind);
		for (int i = 0; i < n; ++i) {
			if (c[i] > sz[i] - 1) {
				pw.println("NO");
				return;
			}
		}
		ArrayDeque<Integer> child = new ArrayDeque<>();
		for (int i = 0; i < n; ++i) {
			child.add(i + 1);
		}
//		System.err.println(Arrays.toString(sz));
		dfs(ind, child);
		pw.println("YES");
		for (int i = 0; i < n; ++i) {
			pw.print(ans[i] + " ");
		}
	}

	void test() throws IOException {
		Random rnd = new Random();
		for (int i = 0; i < 5; ++i) {
			int n = rnd.nextInt(10) + 1;
			int a[] = new int[n];
			System.err.println(n);
			for (int j = 0; j < n; ++j) {
				a[j] = rnd.nextInt(20) + 1;
				System.err.print(a[j] + " ");
			}
//			solve(n, a);
			System.err.println();
		}
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter pw;

	public static void main(String args[]) {
		new Main().run();
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in), 32768);
			pw = new PrintWriter(System.out);
			st = null;
			solve();
			pw.flush();
			pw.close();
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

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