#P1720C. Corners

Corners

Description

You are given a matrix consisting of nn rows and mm columns. Each cell of this matrix contains 00 or 11.

Let's call a square of size 2×22 \times 2 without one corner cell an L-shape figure. In one operation you can take one L-shape figure, with at least one cell containing 11 and replace all numbers in it with zeroes.

Find the maximum number of operations that you can do with the given matrix.

The first line contains one integer tt (1t5001 \leq t \leq 500) — the number of test cases. Then follow the descriptions of each test case.

The first line of each test case contains two integers nn and mm (2n,m5002 \leq n, m \leq 500) — the size of the matrix.

Each of the following nn lines contains a binary string of length mm — the description of the matrix.

It is guaranteed that the sum of nn and the sum of mm over all test cases does not exceed 10001000.

For each test case output the maximum number of operations you can do with the given matrix.

Input

The first line contains one integer tt (1t5001 \leq t \leq 500) — the number of test cases. Then follow the descriptions of each test case.

The first line of each test case contains two integers nn and mm (2n,m5002 \leq n, m \leq 500) — the size of the matrix.

Each of the following nn lines contains a binary string of length mm — the description of the matrix.

It is guaranteed that the sum of nn and the sum of mm over all test cases does not exceed 10001000.

Output

For each test case output the maximum number of operations you can do with the given matrix.

Sample Input 1

4
4 3
101
111
011
110
3 4
1110
0111
0111
2 2
00
00
2 2
11
11

Sample Output 1

8
9
0
2

Note

In the first testcase one of the optimal sequences of operations is the following (bold font shows l-shape figure on which operation was performed):

  • Matrix before any operation was performed:
    101
    111
    011
    110
  • Matrix after 11 operation was performed:
    100
    101
    011
    110
  • Matrix after 22 operations were performed:
    100
    100
    011
    110
  • Matrix after 33 operations were performed:
    100
    100
    010
    110
  • Matrix after 44 operations were performed:
    100
    000
    010
    110
  • Matrix after 55 operations were performed:
    100
    000
    010
    100
  • Matrix after 66 operations were performed:
    100
    000
    000
    100
  • Matrix after 77 operations were performed:
    000
    000
    000
    100
  • Matrix after 88 operations were performed:
    000
    000
    000
    000

In the third testcase from the sample we can not perform any operation because the matrix doesn't contain any ones.

In the fourth testcase it does not matter which L-shape figure we pick in our first operation. We will always be left with single one. So we will perform 22 operations.