The code has been implemented in Python programming language. To run the code,type the command: python filename < input_file The parameters like N and no. of moves can be easily changed .These have been initialized at the beginning and are changed at the last lines of program files.