//#pragma GCC optimize(2)
//#pragma GCC optimize("Ofast","inline","-ffast-math")
//#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include<iostream>
#include<cstdio>
#include<string>
#include<ctime>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<sstream>
#include<cassert>
#include<bitset>
#include<unordered_map>
using namespace std;
      
typedef long long LL;
      
typedef unsigned long long ull;

const int inf=0x3f3f3f3f;
    
const int N=510;

char maze[N][N];

int sum[N][N];

int main()
{
#ifndef ONLINE_JUDGE
//  freopen("data.in.txt","r",stdin);
//  freopen("data.out.txt","w",stdout);
#endif
//  ios::sync_with_stdio(false);
	int w;
	cin>>w;
	while(w--)
	{
		memset(sum,0,sizeof(sum)); 
		int n,m;
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++)
		{
			scanf("%s",maze[i]+1);
			for(int j=1;j<=m;j++)
				sum[i][j]=sum[i][j-1]+(maze[i][j]=='*');
		}
		int ans=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
				for(int k=1;k<=n;k++)
				{
					int l=j-k+1,r=j+k-1;
					if(l<=0||r>m)
						break;
					if(sum[i+k-1][r]-sum[i+k-1][l-1]==r-l+1)
						ans++;
					else
						break;
				}
		printf("%d\n",ans);
	}








/*
1
5 6
.*....
.**...
.***..
.****.
.*****
*/















   return 0;
}