Your task is to solve the problem Depot from the International Olympiad in Informatics, 2001.
When we add a number to a depot, it results in a sequence of moves that ends with some value being appended as the last element in a row. Hence, we can start with the last element in each row and try to "undo" the move that brought it there.
For instance, consider the depot
1 4 5 2 9 3
2 4 5 3 9
1 4 9 2 3
1 4 2 9 3
We can then repeat this analysis to extract the number inserted at the second last step etc, so we reconstruct the original input sequences in reverse order.
Notice that any legal depot will have each row in ascending order and no row can be longer than the row above it.
Submit your solution via Moodle, as a Jupyter notebook, with explanatory comments.