Fixed a stupid bug (MAX_N used instead of MAX_M).