Extend the M matrix to a general n by n