The potential of a vertex in a suspended binary tree is defined as the shortest distance to a vertex with fewer than two children. A tree is termed left if, for every vertex, the potential of the left child is not less than that of the right child. Furthermore, no vertex should have a right child without also having a left child.
Given a binary tree, determine the smallest vertex where this property is violated.
The first line contains the number of vertices in the tree, (1 \leq N \leq 10^5). The following lines provide the indices of the left and right children, l_i and r_i respectively (i < l_i \leq N, i < r_i \leq N). If l_i or r_i is , it indicates the absence of that child.
Print the smallest vertex number where the property is violated, or if the tree satisfies the property for all vertices.
Example 1