Scenario: We have a 5x5 grid (zero-indexed), in which a character starts his journey from (0,0). The character is able to move left, right, up and down within the boundaries of the grid. However, he is able to move up/down only at either end of a row within the grid. For instance, if r represents row, and c represents column in (r,c), he may move up/down at (1,0) or (3,4) and not at (1,1).