/***************************

      KEEP HUSTLING

****************************/

#include<bits/stdc++.h>
using namespace std;
  
  #define   ll              long long
  #define   endl           "\n"
  #define   int           long long
  #define   fo(i,n)          for(i=0;i<n;i++)
  #define   re(i,n)          for(i=n-1;i<=0;i--)
  #define   pb             push_back
    #define   mp             make_pair
  #define   vi             vector<int>
  #define   pii           pair<int,int>
  #define   mii           map<int,int>
  #define   umii           unordered_map<int,int>
  #define   si             set<int>
  #define   usi           unordered_set<int>
  #define   fast           ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  #define    big            LONG_LONG_MAX
  #define   small          LONG_LONG_MIN
  #define   all(x)           x.begin(), x.end()

int mod = pow(10,9)+7;
int inf=1e18;

int Log2(int x){
  int ans=0;
  while(x>>=1)  ans++;
  return ans;
}

int gcd(int a,int b){
  if(b==0)  return a;
  return gcd(b,a%b);
}


void solve(){
  vector<set<pii> >  v(501);
  int n,m;  cin>>n>>m;
  char arr[n][m];
  int w[n][m];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++)  cin>>arr[i][j];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(arr[i][j]=='.')  w[i][j]=0;
      else{
        if(j==0){
          w[i][j]=1;
        }
        else{
          w[i][j]=1+w[i][j-1];
        }
      }
    }
  }


  int ans=0;

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(arr[i][j]=='*'){
        ans++;
        int count=3;
        for(int p=i+1;p<n;p++){
          int q=j+count/2;
          if(q<m){ 
            if(w[p][q]>=count){
              ans++;
            }
            else{
              break;
            }
          }
          count+=2;
        }
      }
    }
  }

  cout<<ans<<endl;
}

void pb_18(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  int t=1;
  cin>>t;
  while(t--)  solve();
}

int32_t main(){
  fast
  pb_18();
  return 0;
}