Hello codeforces. Today I have a very interesting exercise, which is a number sorting game. First of all, let's understand this game.
The interface will consist of a rectangle of m rows and n columns, containing m * n squares of size 1*1. The squares will get a value from 1 to m*n-1 where no 2 cells have the same value, and 1 empty cell is numbered -1. For each step, the player is allowed to change the position of the empty cell (_containing the number -1_) for the adjacent cells. The game will be over if the tiles are in place, an empty cell (bearing number -1) is at the bottom right corner, the remaining numbers are arranged in ascending order from left to right, top to bottom. The figure below is an example of the ending game: