#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <chrono>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;
// fast IO
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
////////// 	Template structure for debugging
#define tr(...) trace(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void trace(const char* name, Arg1&& arg1){
cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void trace(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cout.write(names, comma-names) << " : " << arg1 << " | " ;
trace(comma+1, args...);
}
#define print(...) pr(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void pr(const char* name, Arg1&& arg1){
cout << arg1 << endl;
}
template <typename Arg1, typename... Args>
void pr(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cout << arg1 << " ";
pr(comma+1, args...);
}
void printV(vector<int> &arr)
{
	cout << "Vector : ";
	for(int i=0;i<arr.size();i++)
		cout << arr[i] << " \n"[ i == arr.size()-1 ];
}
void printV(vector<long long> &arr)
{
	cout << "Vector : ";
	for(int i=0;i<arr.size();i++)
		cout << arr[i] << " \n"[ i == arr.size()-1 ];
}void printA(int arr[], int n)
{
	cout << "Array : ";
	for(int i=0;i<n;i++)
		cout << arr[i] << " \n"[ i == n-1 ];
}
//-----------Prime factorization of a number N
	//vector<int> factorize(int N){
		//for(ll i=2; i*i <=N; i++){
		//if(N % i)continue;
		//factors.push_back(i);
		//while(N % i == 0)N /= i;
		//}
		//if(N > 1)factors.push_back(q1);
		//return factors
	//}
//-----------Power for a ^ b
	//int power(int a, int b){
		//int ans = 1;
		//while(b){
		 //if(b&a)ans *= a;
		 //a *= a;
		 //b >>= 1;
		//}
		//return ans
	//}
//-----------factorial of a number n
//int fact(int n){
	//int ans = 1;
	//for(int i=1; i<=n; i++)ans = 1ll * ans * i % MOD;
	//return ans;
//}
//-----------N C r
//int ncr(int n, int r){
	//if(r > n)return 0;
	//if(r==0 || n==0)return 1;
	//if(r==1)return n;
	//int a = fact(n), b = 1ll * fact(n-r) % MOD, c = 1ll * fact(r) % MOD;
	//int ans = 1ll * a * power(b, MOD-2) % MOD;
	//ans = 1ll * ans * power(c, MOD-2) % MOD;
	//return ans;
//}
//--------- Modular division
//int divide(int a, int b, int MOD){
	//return a * power(b, MOD-2);
//}
//------------------sieve of Eratosthenes
//
//arr[0] = 1;
//arr[1] = 1;
//for(int i=2; i*i <= N; i++){
	//if(!arr[i]){
		//for(int j=i*i; j<=N; j++)
			//arr[j] = 1;
	//}
//}
//
int t, n, m;
void solve(){
	cin >> n >> m;
	vector<vector<char>> arr(n, vector<char>(m, '.'));
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++)
			cin >> arr[i][j];

	vector<vector<int>> dp(n, vector<int>(m, 0));
	for(int i=0; i<n; i++){
		int count = 0;
		for(int j=0; j<m; j++)
		{
			count = arr[i][j] == '*' ? count + 1 : 0;
			dp[i][j] = count;
		}
		count = 0;
		for(int j=m-1; j>=0; j--){
			count = arr[i][j] == '*' ? count + 1 : 0;
			dp[i][j] = min(dp[i][j], count);
		}
	}

	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			for(int rr=i; rr<n; rr++)
			{
				if(dp[rr][j] < rr-i+1)break;
				ans++;
			}
		}
	}
	cout << ans << endl;
}

int main() {
	cin >> t;
	while(t--)solve();
}
