CODECHEF - Counting Matrices (April Challenge 2014)

http://www.codechef.com/APRIL14/problems/CNPIIM/