Matrix Resurrection

We have a two-dimensional matrix consisting of NNN rows and MMM columns. The rows are numbered from 111 to NNN and the columns are numbered from 111 to MMM. Two cells of the matrix will be called adjacent if they share a side vertically, horizontally, or diagonally.


This is a companion discussion topic for the original entry at https://toph.co/p/matrix-resurrection