We want to build a ternary min heap given a sequence of push and pop. In a d-ary heap, each node can have up to d children. In a min heap, each parent node has a key no greater than that of its children.
The first line contains the degree of the heap (d), the max. number of children a node can have.
The second line contains the number of operations (push and pop) made to the ternary min heap.
Then, each line is a push (with an int key value) or pop operation.
There's no duplicate keys and no underflow cases (i.e., requesting an empty heap to perform pop).
Print out the level-order sequence of the ternary min heap after all operations are made.