Escape Plan

Mrs. Worm owns a coal mine that can be represented as a network of NN nodes numbered from 11 to NN. Node 11 is the entrance to the mine, and for each other node ii there is a one-way tunnel going from a node PiP_i to ii, with Pi<iP_i < i. Nodes that don’t have any tunnels coming out of them are called mining shafts.

The Nlogonia government conducted a safety inspection of the mine and noted that, in case of an emergency, workers could be stuck inside the mining shafts, unable to escape. Mrs. Worm will certainly get sued unless she acts quickly!

To avoid this problem, Mrs. Worm decided to dig a set of one-way escape tunnels leading out from the mining shafts. This set must meet the following conditions:

  1. Each mining shaft ss has exactly one escape tunnel going from ss to a node e(s)e(s), in such a way that there is a path from e(s)e(s) to ss using only the original N−1N-1 tunnels.

  2. Each node has at most one escape tunnel that leads to it.

  3. There is a path from each mining shaft to the entrance, if both the original tunnels and the escape tunnels can be used.

Mrs. Worm needs your help! Find a valid set of escape tunnels that saves her from being sued or tell her that it is impossible to do so.

Input

The first line contains an integer NN (2≤N≤5×1052 \leq N \leq 5 \times 10^{5}) representing the number of nodes in the coal mine. Each node is identified by a distinct integer from 11 to NN.

The second line contains N−1N - 1 integers P2,P3,…,PN{P_2}, {P_3}, \ldots, {P_N} (1≤Pi<i1 \leq P_i < i), representing that there is a tunnel going from node PiP_i to node ii.

Output

Output a single line with NN integers E1,E2,…,EN{E_1}, {E_2}, \ldots, {E_N}, such that Ei=e(i)E_i=e(i) if node ii is a mining shaft, and Ei=0E_i=0 otherwise. If there are multiple solutions, output any of them.

If there is no valid set of escape tunnels, output a single line with the character “*” (asterisk) instead.

Examples

Input

2
1

Output

0 1

Input

3
1 1

Output

*

Input

8
1 2 3 4 4 2 7

Output

0 0 0 0 1 3 0 2

Explanation

Nodes 5, 6 and 8 are the mining shafts. The figure below shows four possible sets of escape tunnels for this test case. The first three sets are invalid, each one breaking one of the conditions. The last set is the proposed output e(5) = 1, e(6) = 3 and e(8) = 2, which is valid.

Invalid: e(6) = 8, but there is no path from node 8 to node 6 using only the original tunnels.
Invalid: two escape tunnels lead to node 1.
Invalid: mining shaft 8 cannot reach the entrance.
Valid: the set of escape tunnels of the output.
Valid: the set of escape tunnels of the output.