you give m x n integer matrix grid m n integer integer kThe matrix compose layer show image color layera cyclic rotation matrix cyclically rotate layer matrix to cyclically rotate layer element layer place adjacent element counterclockwise direction an example rotation show belowreturn matrix apply k cyclic rotation example 1input grid 40103020 k 1Output 10204030explanation the figure represent grid stateExample 2input grid 12345678910111213141516 k 2output 34812211101617615591314explanation the figure represent grid state Constraintsm gridlengthn gridilength2 m n 50both m n integers1 gridij 50001 k 109