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: rain 80 toy 73 63 wall
Step I: 63 rain 80 toy 73 wall
Step II: 63 73 rain 80 toy wall
Step III: 63 73 80 rain toy wall
Following the same rule, the machine is given this input: umbrella 22 65 jug 20 ship
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: 20 umbrella 22 65 jug ship; Step II: 20 22 umbrella 65 jug ship; Step III: 20 22 65 umbrella jug ship.
Answer: 20 22 65 umbrella jug ship