tree.in
tree.out
Suppose we want to draw a binary tree in a grid obeying the following rules:
The levels are numbered from 1 starting form the root node. The width of each level is defined to be the distance from the left edge of the column of the leftmost node to the right edge of the column of the rightmost node in the level.
The following figure shows a binary tree drawn obeying the above rules. The width of the first level is 1, the width of the second level is 13, and the widths of the third, fourth, fifth, and sixth are 18, 18, 13, and 12, respectively.

Given a binary tree, write a program to compute the level with the maximal width and the width of that level.
The first line of input file contains a single integer N (1 ≤ N ≤ 1,000), the number of nodes in the tree. The nodes are numbered from 1 to N, with 1 being the root node. Each of the following N lines consists of three integers, where the first is a node and the second and the third are the left and the right child of the first node, respectively. A missing child is denoted by -1.
The first and only line of the output file must contain two integers: the level with the maximal width and its width. If there are several levels with the maximal width, output the smallest level number.
19 1 2 3 2 4 5 3 6 7 4 8 -1 5 9 10 6 11 12 7 13 -1 8 -1 -1 9 14 15 10 -1 -1 11 16 -1 12 -1 -1 13 17 -1 14 -1 -1 15 18 -1 16 -1 -1 17 -1 19 18 -1 -1 19 -1 -1
3 18