Return a list of (index, value) pairs for every element of the 2-D array Z, in row-major order, where index is a (row, col) tuple and value is an int.
(index, value)
Z
index
(row, col)
value
solve(...)