You’ll be given two matrix **M1** and **M2** and another integer **K**. The size of both M1 and M2 are **N*N** and each of their cells contains either **0** or **1**. You have to find in how many ways you can select a sub-matrix **S1** from M1 and another sub-matrix **S2** from M2 (both of size **K*K**) such that they look exactly same.

This is a companion discussion topic for the original entry at https://toph.co/p/photo-matching