How to solve MNTILE - Tiling a Grid With Dominoes problem on SPOJ?

Problem Link

P.S.: solved M3TILE and M4TILE…