Add support for M!=N case