Is this the left pile?
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.
Input
The first line contains the number of vertices in the tree, N (1 ≤ N ≤ 10^5). The following N lines provide the indices of the left and right children, l_i and r_i respectively (i < l_i ≤ n, i < r_i ≤ n). If l_i or r_i is -1, it indicates the absence of that child.
Output
Print the smallest vertex number where the property is violated, or -1 if the tree satisfies the property for all vertices.