You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares: squares with each side parallel to a side of the matrix; squares with each side parallel to a diagonal of the matrix. For example the following matrix contains only one square of the first type: 0000000 0111100 0100100 0100100 0111100 The following matrix contains only one square of the second type:00000000010000010100000100000000000 Regardless of type, a square must contain at least one 1 and can't touch (by side or corner) any foreign 1. Of course, the lengths of the sides of each square should be equal. How many squares are in the given matrix?
输入描述:
The first line contains integer t (1 ≤ t ≤ 10000), where t is the number of test cases in the input. Then test cases follow. Each case starts with a line containing integers n and m (2 ≤ n, m ≤ 250), where n is the number of rows and m is the number of columns. The following n lines contain m characters each (0 or 1).The total number of characters in all test cases doesn't exceed 106 for any input file.


输出描述:
You should output exactly t lines, with the answer to the i-th test case on the i-th line.
示例1

输入

2<br />8 8<br />00010001<br />00101000<br />01000100<br />10000010<br />01000100<br />00101000<br />11010011<br />11000011<br />10 10<br />1111111000<br />1000001000<br />1011001000<br />1011001010<br />1000001101<br />1001001010<br />1010101000<br />1001001000<br />1000001000<br />1111111000<br />1<br />12 11<br />11111111111<br />10000000001<br />10111111101<br />10100000101<br />10101100101<br />10101100101<br />10100000101<br />10100000101<br />10111111101<br />10000000001<br />11111111111<br />00000000000<br />

输出

1<br />2<br />3<br />
加载中...