different neighbour question,long challenge

the question seems confusing can any one give me one more example for the question.
like what would be output if we have 5 columns and 4 rows?

for n=4 and m=5 one possible solution can be:

4

3 1 2 2 1

2 1 3 4 4

4 4 3 1 2

1 2 2 1 3

there can be different solution for n=4 and m=5 but it will be accepted if it is correct.

@ask_daddy , I hope this will help you.