A binary tree of part ids is given in level-order form (a single line of space-separated tokens, null marking a missing child; every non-null node contributes exactly two following tokens for its children).
Imagine the tree drawn on a grid: the root sits at column 0, row 0. For any node at column c and row r, its left child (if present) sits at column c-1, row r+1, and its right child (if present) sits at column c+1, row r+1.
Scan the grid column by column, from the smallest column index to the largest. Within a column, list nodes from the smallest row to the largest; if two nodes land on the exact same column and row, list them in ascending order of value.
Print every value in this column-major order, space-separated, on one line.
Input format
Line 1: space-separated level-order tokens describing the binary tree (integers and the token null).
Output format
A single line: the values in column-major order as defined above (empty line if the tree is empty).
Constraints
- 0 <= number of nodes <= 400
- Each node value is an integer with -1000 <= value <= 1000