Hiding a Tree

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

XOR-scanner is a device which scans a sequence of integers and accepts it if and only if the bitwise XOR of all numbers in the sequence is equal to zero.

You have a tree with nn vertices, labeled with integers from 11 to nn. You want to write down this tree in a standard format for the programming contest problem:

nn
u_1 v_1u\_1\ v\_1
\dots
u_n1 v_n1u\_{n-1}\ v\_{n-1}

Here nn is the number of vertices and u_iu\_i, v_iv\_i are vertices connected by the ii-th edge.

You want the XOR-scanner to accept your output. It might be not the case initially, so you can change the labels of some vertices of the tree. After this operation all vertices must have distinct integer labels from 11 to 10910^9, inclusive.

For each vertex it is known if it is possible to change its label. Find a way to relabel some allowed vertices (possibly, keeping some labels or all of them as is) in such a manner that the XOR-scanner accepts the tree representation or report that it is impossible.

입력

In the first line there is an integer nn (2n100,0002 \leq n \leq 100\\,000), the number of vertices in a tree. 

Next line contains nn integers, ii-th of them is 00 if the label of ii-th vertex is fixed and 11 if it can be changed.

Each of the next n1n-1 lines contains two integers u_iu\_i, v_iv\_i (1u_i,v_in1 \leq u\_i, v\_i \leq n), which denote the endpoints of the edges.

출력

If the desired relabeling exists, print the relabeled tree in the same format as it is given in the statement, keeping the order of edges and the order of endpoints of the each edge. The bitwise XOR of all printed numbers must be zero.

If it is impossible, print a single number -1.