Everybody knows about binary tree, a binary tree is a tree data structure in which each node has at most two children.
A Binary tree is Perfect Binary Tree in which all internal nodes have two children and all leaves are at same level. Here are some examples of perfect binary tree
Now your task is to draw perfect binary tree. You will be given which is the number of nodes of a perfect binary tree. Suppose is 3 then you have to print like first sample output, if is 7 You have to print like second sample output where node of a tree will be printed as capital 'O' and gaps before a node will be printed as hyphen '-'. You can assume that the value of will be valid always.
Each line of input will contain (). Input will be terminated by end of file.
For each value of you have to print a perfect binary tree according to rules mentioned above. Print a blank line after each test case.
Input | Output |
---|---|
3 7 | -O O-O ---O -O---O O-O-O-O |