#GYM104599H. Light Tree

Light Tree

Description

Will has been transported to another dimension and is unable to escape on his own! Fortunately, since he is a brilliant computer scientist, Will has found a way to communicate with his mother, Joyce, by building figures resembling a binary tree using LED lights connected by metal rods. The initial LED lights (up to two) are connected to a power source by metal rods, and more LED lights can stem from these, with at most two rods emanating from each light, one to the left and one to the right.

Will has used $N$ lights numbered $1-N$. Joyce has figured out that the depth $D$ of an LED light with no rods emanating from it, called an "end light," corresponds to the $D$th letter of the alphabet. The power source has a depth of 0; light $1$ emanates from it to the left, and light $2$ emanates from it to the right. The lights should be read from left to right, with all the end lights emanating from a given left rod being read before any of the end lights from the corresponding right rod. Given the information for each light, help Joyce decode Will's message so she can locate her son!

Line $1$: An integer $N$

Lines $2…N$+1: $N$ lines denoting, in order, the information for the $N$ lights. Each line contains two integers: the number of the left light and the right light emanating from it (or $0$ if there is no light).

Line $1$: An all-uppercase string representing the decoded message.

Input

Line $1$: An integer $N$

Lines $2…N$+1: $N$ lines denoting, in order, the information for the $N$ lights. Each line contains two integers: the number of the left light and the right light emanating from it (or $0$ if there is no light).

Output

Line $1$: An all-uppercase string representing the decoded message.

5
3 4
0 0
0 0
0 5
0 0
BCA

Note

$2 <= N <= 10^5$