A word and number arrangement machine rearranges an input line step by step, following a rule. Here is an illustration of the input and the steps:
Input: sun 69 night 43 44 jug
Step I: 43 sun 69 night 44 jug
Step II: 43 44 sun 69 night jug
Step III: 43 44 69 sun night jug
Following the same rule, the machine is given this input: house 87 16 wind 96 toy
What is the final arrangement (the last step)?
Rule (from the illustration): In each step the smallest number not yet arranged moves to the left end, after the numbers already arranged; the words keep their order.
For the new input: Step I: 16 house 87 wind 96 toy; Step II: 16 87 house wind 96 toy; Step III: 16 87 96 house wind toy.
Answer: 16 87 96 house wind toy