 #include<iostream>
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
using namespace std;



int main()
{  
     #ifndef ONLINE_JUDGE
     //for getting input from file input.txt
     freopen("input.txt","r",stdin);
    //for writing output to output.txt
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(NULL);
  
 ll t;
 cin>>t;
 while(t--)
 { 
     
   ll n,m,i;
   cin>>n>>m;
   string s[n];
   for(i=0;i<n;i++)
    cin>>s[i];
       ll j,k,add=0,ans=0;

       ll dp[n][m];

       for(i=0;i<n;i++)
       {  j=0;
        if(s[i][j]=='*')
            dp[i][j]=1;
        else
            dp[i][j]=0;
        for(j=1;j<m;j++)
        {
             if(s[i][j]=='*')
            dp[i][j]=dp[i][j-1]+1;
        else
            dp[i][j]=dp[i][j-1];
        }
       }
   for(i=0;i<n;i++)
   {
    for(j=0;j<m;j++)
    {   
        ll add=0,temp=0,k=i,star=0,count=0;
        if(s[i][j]=='*')
        {
                 while(j>=add && k<n && j<m-add)
                 {
                         if(s[k][j-add]=='*')
                         {
                            count = dp[k][j+add]-dp[k][j-add]+1;
                         }
                         else
                            count = dp[k][j+add]-dp[k][j-add];
                       // if(n==2 && m==3)
                        //cout<<count<<"*";

                             if(count!=(2*(add)+1))
                                break;
                            else
                            {
                                add++;
                                k++;
                                ans++;
                            }

                 }
        }
    }
   }

   cout<<ans<<endl;

  }


}
   
 
 