If you had played the Snake game in old Nokia phones then you had an awesome childhood because all the memories we have with these legendary phones of our parents are unparalleled. In this problem, your task is about to do something similar to the Snake game. The task is described in the following,
Imagine a python starts moving from the top left corner of a (M by N) grid. The initial moving direction of the python is always to the right. It moves one edge adjacent cell if the next cell is empty or the next cell is within the M by N grid. The snake turns clockwise if there is no space to move to the next forward cell. It stops moving when it can't move anymore. Some rules of the path that the python follows are as follows,
Your task is to print the path representing with '#' hash character and empty cells with a space character.
Each test case contains two integers M & N in one line that denotes the row and column numbers of the grid.
3 <= M, N <= 10^3
Print the M by N grid with the path of the python representing with '#' characters.
Input | Output |
---|---|
10 10 | ########## # ######## # # # # # #### # # # # # # # # # # # # ###### # # # ########## |
Input | Output |
---|---|
11 10 | ########## # ######## # # # # # #### # # # # # # # # # ## # # # # # # # ###### # # # ########## |