
#include <bits/stdc++.h> // Include every standard library 
using namespace std;


//data types
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

//constants
double eps = 1e-9;
int inf = 1000000005;
int mod = 1000000007;
long long INFF = 1000000000000000005ll;
double PI = acos(-1);

//loops
#define FOR(i,a,b) for ( i = (a); i < (b); ++i)
#define FORN(i,a) FOR(i,0,a)
#define ROF(i,a,b) for ( i = (b)-1; i >= (a); --i)
#define ROFN(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

//helpful functions
#define mem(a, b) memset(a, b, sizeof(a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define next next_permutation
#define perv prev_permutation
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);
#define setbit(x) __builtin_popcount(x)
#define ctz(x) __builtin_ctz(x)
#define clz(x) __builtin_clz(x)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define tc(t) while (t--)

//input,ouput
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int n = 600, m = 600;


int main()
{

	fast_io

	int i, j, k;
	int t;

	cin >> t;
	tc(t)
	{
		int row, col; cin >> row >> col;
		char a[row + 1][col + 1];
		int width[row + 1][col + 1];
		int l, r;
		int x, y;
		int ans = 0;
		FOR(i, 1, row + 1)
		{
			FOR(j, 1, col + 1)
			{
				cin >> a[i][j];
				width[i][j] = 0;
				// if (a[i][j] == '*')ans++;

			}
		}


		int cnt1 = 0, cnt2 = 0;
		FOR(i, 1, row + 1)
		{
			FOR(j, 1, col + 1)
			{
				if (a[i][j] == '*')
				{
					l = j - 1; r = j + 1;
					cnt1 = 1, cnt2 = 1;
					while (l >= 1)
					{
						if (a[i][l--] == '*')cnt1++;
						else break;
					}
					while (r <= col)
					{
						if (a[i][r++] == '*')cnt2++;
						else break;
					}
					width[i][j] = min(cnt1, cnt2);
				}
			}
		}
		// FOR(i, 1, row + 1)
		// {
		// 	FOR(j, 1, col + 1)
		// 	{

		// 		cout << width[i][j] << " ";
		// 		// if (a[i][j] == '*')ans++;

		// 	} cout << endl;
		// }
		FOR(i, 1, row + 1)
		{
			FOR(j, 1, col + 1)
			{
				if (a[i][j] == '*')
				{

					k = 1;
					FOR(x, i, row + 1)
					{
						// cout << width[x][j] << " ";
						if (width[x][j] >= k )ans++;
						else break;
						k ++;
					}
					// cout << endl;
				}

			}
		}

		cout << ans << endl;
	}

	return 0;
}

