Anina’s Birthday Gift

Limits 1s, 512 MB

Anina is a girl who is very much interested in mathematics. She likes to solve Geometry and Counting problems very much. Today is Anina's birthday. Her parents got her a birthday cake of size nmn * m unit area. If we consider the cake as a nmn * m size grid then some of the cell contains strawberry and some of the cell doesn’t.

Anina likes to eat strawberries very much. So she wants to have that portion of cake which is full of strawberries and has a square shape. In the above picture 11means the cell contains a strawberry and 00 means doesn’t.

As a friend of Anina I want to give her a counting problem for her birthday. The problem is how many ways Anina can cut a portion from the cake according to her preference ? But to cross check  Anina’s reply I need to know the exact answer. Can you please solve this problem for me ?


The first line of each test case contains two integers n and m (1n,m11)(1≤n,m≤11)  — the number of rows and columns, respectively.

The following nn lines contain mm integers each, the jj -th element in the ii-th line is either00or 11 which indicates that there is a strawberry or not.


Print the answer for the mentioned problem.


4 5
1 0 0 0 0
0 1 1 1 0
0 0 1 1 1
0 1 1 1 0