#include <bits/stdc++.h>   char str[260][260];   int main(void) {     int t, n, m;     scanf( %d , &t);     while (t--) {       int ans = 0;       scanf( %d%d , &n, &m);       getchar();       for (int i = 0; i < n; i++) gets(str[i]);       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (str[i][j] ==  1 ) {             if (str[i][j + 1] ==  1 ) {               if (i >= 1 && str[i - 1][j] ==  1 ) continue;               if (j >= 1 && str[i][j - 1] ==  1 ) continue;               if (i >= 1 && j >= 1 && str[i - 1][j - 1] ==  1 ) continue;               for (int k = 1; k + i < n && k + j < m; k++) {                 if (str[i + k][j] ==  0 ) break;                 if (str[i][j + k] ==  0 ) break;                 if (j >= 1 && str[i + k][j - 1] ==  1 ) break;                 if (i >= 1 && str[i - 1][j + k] ==  1 ) break;                 if (str[i + k][j + k] ==  0 ) continue;                 if (j + k + 1 < m && str[i + k][j + k + 1] ==  1 ) continue;                 if (i + k + 1 < n && str[i + k + 1][j + k] ==  1 ) continue;                 if (i + k + 1 < n && j + k + 1 < m &&                     str[i + k + 1][j + k + 1] ==  1 )                   continue;                 if (i + k + 1 < n && str[i + k + 1][j] ==  1 ) continue;                 if (j + k + 1 < m && str[i][j + k + 1] ==  1 ) continue;                 if (i + k + 1 < n && j >= 1 && str[i + k + 1][j - 1] ==  1 )                   continue;                 if (j + k + 1 < m && i >= 1 && str[i - 1][j + k + 1] ==  1 )                   continue;                 int flag = 0;                 for (int p = 1; p < k && flag == 0; p++) {                   if (str[i + k][j + p] ==  0 ) flag = 1;                   if (str[i + p][j + k] ==  0 ) flag = 1;                   if (j + k + 1 < m && str[i + p][j + k + 1] ==  1 ) flag = 1;                   if (i + k + 1 < n && str[i + k + 1][j + p] ==  1 ) flag = 1;                   if (str[i + k - 1][j + p] ==  1 ) flag = 1;                   if (str[i + p][j + k - 1] ==  1 ) flag = 1;                   if (str[i + 1][j + p] ==  1 ) flag = 1;                   if (str[i + p][j + 1] ==  1 ) flag = 1;                 }                 if (!flag) {                   ans++;                   break;                 }               }             } else {               int flag = 1;               for (int k = 2; k + i < n; k += 2) {                 if (j + k / 2 >= m || j - k / 2 < 0) break;                 if (str[i + k][j] ==  1 ) {                   flag = 1;                   if (i >= 1 && str[i - 1][j] ==  1 ) break;                   if (j >= 1 && str[i][j - 1] ==  1 ) break;                   if (j < m && str[i][j + 1] ==  1 ) break;                   if (i >= 1 && j + 1 < m && str[i - 1][j + 1] ==  1 ) break;                   if (i >= 1 && j >= 1 && str[i - 1][j - 1] ==  1 ) break;                   if (str[i + 1][j] ==  1 ) break;                   if (str[i + k - 1][j] ==  1 ) continue;                   if (i + k + 1 < n && str[i + k + 1][j] ==  1 ) continue;                   if (j >= 1 && str[i + k][j - 1] ==  1 ) continue;                   if (j + 1 < m && str[i + k][j + 1] ==  1 ) continue;                   if (i + k + 1 < n && j >= 1 && str[i + k + 1][j - 1] ==  1 )                     continue;                   if (i + k + 1 < n && j + 1 < m && str[i + k + 1][j + 1] ==  1 )                     continue;                   if (j - k / 2 - 1 >= 0 && str[i + k / 2][j - k / 2 - 1] ==  1 )                     continue;                   if (str[i + k / 2][j - k / 2 + 1] ==  1 ) continue;                   if (str[i + k / 2 - 1][j - k / 2] ==  1 ) continue;                   if (str[i + k / 2 + 1][j - k / 2] ==  1 ) continue;                   if (j >= 1 && str[i + k / 2 - 1][j - k / 2 - 1] ==  1 )                     continue;                   if (j >= 1 && str[i + k / 2 + 1][j - k / 2 - 1] ==  1 )                     continue;                   if (str[i + k / 2 - 1][j + k / 2] ==  1 ) continue;                   if (str[i + k / 2 + 1][j + k / 2] ==  1 ) continue;                   if (str[i + k / 2][j + k / 2 - 1] ==  1 ) continue;                   if (j + k / 2 + 1 < m && str[i + k / 2][j + k / 2 + 1] ==  1 )                     continue;                   if (j + k / 2 + 1 < m &&                       str[i + k / 2 - 1][j + k / 2 + 1] ==  1 )                     continue;                   if (j + k / 2 + 1 < m &&                       str[i + k / 2 + 1][j + k / 2 + 1] ==  1 )                     continue;                   flag = 0;                   for (int p = 1; p <= k / 2 && flag == 0; p++) {                     if (str[i + p][j + p] ==  0  ||                         str[i + p + 1][j + p] ==  1  ||                         str[i + p - 1][j + p] ==  1 )                       flag = 2;                     if (str[i + p][j - p] ==  0  ||                         str[i + p + 1][j - p] ==  1  ||                         str[i + p - 1][j - p] ==  1 )                       flag = 2;                     if (str[i + k - p][j + p] ==  0  ||                         str[i + k - p + 1][j + p] ==  1  ||                         str[i + k - p - 1][j + p] ==  1 )                       flag = 1;                     if (str[i + k - p][j - p] ==  0  ||                         str[i + k - p + 1][j - p] ==  1  ||                         str[i + k - p - 1][j - p] ==  1 )                       flag = 1;                   }                   if (flag == 2) break;                   if (flag == 1) continue;                   for (int p = 1; p < k / 2 && flag == 0; p++) {                     if (str[i + p - 1][j + p + 1] ==  1 ) flag = 2;                     if (str[i + p + 1][j + p - 1] ==  1 ) flag = 2;                     if (str[i + k - p - 1][j - p + 1] ==  1 ) flag = 1;                     if (str[i + k - p + 1][j - p - 1] ==  1 ) flag = 1;                     if (str[i + p - 1][j - p - 1] ==  1 ) flag = 2;                     if (str[i + p + 1][j - p + 1] ==  1 ) flag = 2;                     if (str[i + k - p - 1][j + p - 1] ==  1 ) flag = 1;                     if (str[i + k - p + 1][j + p + 1] ==  1 ) flag = 1;                   }                   if (flag == 2) break;                   if (flag == 1) continue;                 }                 if (!flag) {                   ans++;                   break;                 }               }             }           }         }       }       printf( %d n , ans);     }     return 0;   }