There is an NxN square with its cells initially empty. The rows of the square are indexed from top to bottom, and columns from left to right. All indices start from 0.
You wish to fill the cells of the square with consecutive integers, starting from 1, using the following algorithm. At the beginning you stand at the topmost leftmost cell and put 1 in this cell. Each time you want to find the cell for the next number, you use the following method: Move a cells down and b cells right from your current cell (all moves are cyclic, so moving down one row from row N-1 takes you to row 0, and moving right one column from column N-1 takes you to column 0). If the current cell is empty, then you put the next number in this cell. Otherwise, move an additional c cells down and d cells right. If the current cell is empty, then you put the next number in this cell, otherwise the entire algorithm is finished.
Return a String describing the final state of the square after the algorithm is finished. The i-th element of the return should be a list of N integers, separated by single spaces and without leading or trailing spaces. The j-th integer in this list should be the integer written in the cell in row i, column j of the square, or -1 if this cell is empty.