Hi. Welcome to stackoverflow. Number of permutations is definitely NOT M^N. For 2x2 matrix in your example, 2^2 = 4 is not 16 as you yourself have mentioned. Number of permutations is
2^(M*N)
. Also, this site is for programmers.
math.stackexchange.com is much better suited for math questions. —
NoShady420 23 secs ago