Given an integer number K, generate a tree with minimum number of nodes such that there are exactly K pairs of nodes (X, Y), where X is an ancestor of Y.
The input (from the console) will contain a single integer number, K – the number of pairs with the specified property.
The output (to the console) will contain N+1 lines, representing the generated tree, the nodes being indexed from 0.
The first line will contain the number N – the number of nodes in the tree.
The following N lines will contain each 2 numbers X and T, separated by a space, with the following meaning: node T is the direct ancestor of node X. If node X doesn’t have a direct ancestor, T will have value -1.