

You are given an arbitrary binary tree consisting of N nodes numbered from 1 to N, your task is to print the nodes of this tree in the vertical order.
V1, V2, V3, V4 and V5 in the above figure denotes the vertical levels of the given binary tree. Now, if we want to print the tree in the vertical order, then we will start printing the node values on the segment V1 and will continue the same procedure till the segment V5, and while printing the node values for any vertical level, we will check if there is any node to the left of the current level which does not lie on any of the line segment then we will include that node also in the current level. For instance node with value 7 can be included in the level V3, and the node with value 8 can be included in the level V4.
The vertical traversal for the above binary tree would be 6 4 2 7 8 3 9.
Note:
1) The root node will be fixed and will be provided in the function.
2) Two nodes in the tree can have the same values, all values in the tree will be positive.
3) While printing the nodes for any particular vertical level print them in sorted order, i.e. in the above example nodes in the level 3 are 2,7 and 8 so it will be printed as 2 7 8.
The first line of the input contains a single integer T, representing the number of test cases.
The first line of each test case contains a single integer N denoting the number of nodes in the tree.
The second line contains the values of the nodes of the tree in the level order form ( -1 for NULL node) Refer to the example for further clarification.
Example: Consider the binary tree

1
2 3
4 -1 5 6
-1 7 -1 -1 -1 -1
-1 -1
Explanation :
Level 1 :
The root node of the tree is 1
Level 2 :
Left child of 1 = 2
Right child of 1 = 3
Level 3 :
Left child of 2 = 4
Right child of 2 = null (-1)
Left child of 3 = 5
Right child of 3 = 6
Level 4 :
Left child of 4 = null (-1)
Right child of 4 = 7
Left child of 5 = null (-1)
Right child of 5 = null (-1)
Left child of 6 = null (-1)
Right child of 6 = null (-1)
Level 5 :
Left child of 7 = null (-1)
Right child of 7 = null (-1)
The first not-null node (of the previous level) is treated as the parent of the first two nodes of the current level. The second not-null node (of the previous level) is treated as the parent node for the next two nodes of the current level and so on.
The input ends when all nodes at the last level are null (-1).
Output Format:
For each test case, print X space-separated integers, denoting the node values in the order as described in the problem statement.
Note:
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= N <= 10^4
1 <= nodeVal <= 10^9
Time Limit: 1sec
1
3
1 2 3 -1 -1 -1 -1
2 1 3
Vertical level V1 will cover the node with value 2 only, then vertical level V2 covers node with value 1, and vertical level 3 will cover the nodes with value 3. So the final answer will be 2 1 3
1
4
5 6 7 8 -1 -1 -1 -1 -1
8 6 5 7
The vertical level V1 will cover the node with value 8, level V2 will cover node with value 6, level V3 will cover the node with value 8 and the level V4 will cover the node with value 7.
Level- Order Traversal.
O(N), where N is the number of nodes in the tree.
O(N), where N is the number of nodes in the tree.