Write a program to simulate the movements of a robot located in a rectangular world with n rows and m columns. The robot receives a sequence of orders about where to move, either to the right, to the left, upwards or downwards. The simulation must end if any instruction is incorrect or if the robot goes out of the world.
Input
The first line contains two strictly positive natural numbers n and m. The second line has the initial row (between 1 and n) and the initial column (between 1 and m). Follow several orders, one per line. Each order is a non-empty word made up of only lowercase letters.
Output
Print the positions visited by the robot, starting with the initial position. If the robot goes out of the world, or if any order is not “right”, “left”, “up” or “down”, print “out of bounds” or “incorrect order” and stop the simulation.
Input
10 20 5 5 right up left down
Output
(5, 5) (5, 6) (4, 6) (4, 5) (5, 5)
Input
3 7 2 6 right diagonal down
Output
(2, 6) (2, 7) incorrect order
Input
5 1 3 1 down down down down down
Output
(3, 1) (4, 1) (5, 1) out of bounds