#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005
int modexp(int x,int n,int mod){
	x%=mod;
	int res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n/=2;
	}
	return res;
}
int modInverse(int n, int p)
{
    return modexp(n, p - 2, p);
}
int nCr(int n,int r, int p)
{
    if (r == 0)
        return 1;
    int fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}
//vector <int> v[2000005];
signed main()
{
	fast;
	int t=1;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		string s;
	    cin>>s;
	    int i,j,k;
	    vector <int> v;
	    for(i=0;i<=n-1;i++)
	    {
	    	if(s[i]=='*')
	    	{
	    		v.pb(i+1);
			}
		}
		int m=v.size();
		int pref[m];
		int suff[m];
		pref[0]=0;
		int ans=INF;
		for(i=1;i<=m-1;i++)
		{
			pref[i]=pref[i-1]+v[i-1];
		}
		suff[m-1]=0;
		for(i=m-2;i>=0;i--)
		{
			suff[i]=suff[i+1]+v[i+1];
		}
//		for(i=0;i<=m-1;i++) cout<<v[i]<<" ";
//		cout<<endl;
//		for(i=0;i<=m-1;i++) cout<<pref[i]<<" ";
//		cout<<endl;
//		for(i=0;i<=m-1;i++) cout<<suff[i]<<" ";
//		cout<<endl;
		for(i=0;i<=m-1;i++)
		{
			int x=suff[i]-v[i]*(m-i-1)-((m-i-1)*(m-i))/2;
			int y=v[i]*(i)-pref[i]-((i)*(i+1))/2;
			ans=min(ans,x+y);
		}
		if(ans==INF) cout<<0<<endl;
		else cout<<ans<<endl;
	}
   return 0;
}

### Prompt

Your challenge is to write a Cpp solution to the following problem:

You are playing the game "Arranging The Sheep". The goal of this game is to make the sheep line up. The level in the game is described by a string of length n, consisting of the characters '.' (empty space) and '*' (sheep). In one move, you can move any sheep one square to the left or one square to the right, if the corresponding square exists and is empty. The game ends as soon as the sheep are lined up, that is, there should be no empty cells between any sheep.

For example, if n=6 and the level is described by the string "**.*..", then the following game scenario is possible: 

  * the sheep at the 4 position moves to the right, the state of the level: "**..*."; 
  * the sheep at the 2 position moves to the right, the state of the level: "*.*.*."; 
  * the sheep at the 1 position moves to the right, the state of the level: ".**.*."; 
  * the sheep at the 3 position moves to the right, the state of the level: ".*.**."; 
  * the sheep at the 2 position moves to the right, the state of the level: "..***."; 
  * the sheep are lined up and the game ends. 



For a given level, determine the minimum number of moves you need to make to complete the level.

Input

The first line contains one integer t (1 ≤ t ≤ 10^4). Then t test cases follow.

The first line of each test case contains one integer n (1 ≤ n ≤ 10^6).

The second line of each test case contains a string of length n, consisting of the characters '.' (empty space) and '*' (sheep) — the description of the level.

It is guaranteed that the sum of n over all test cases does not exceed 10^6.

Output

For each test case output the minimum number of moves you need to make to complete the level.

Example

Input


5
6
**.*..
5
*****
3
.*.
3
...
10
*.*...*.**


Output


1
0
0
0
9

### Response

```cpp
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005
int modexp(int x,int n,int mod){
	x%=mod;
	int res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n/=2;
	}
	return res;
}
int modInverse(int n, int p)
{
    return modexp(n, p - 2, p);
}
int nCr(int n,int r, int p)
{
    if (r == 0)
        return 1;
    int fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}
//vector <int> v[2000005];
signed main()
{
	fast;
	int t=1;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		string s;
	    cin>>s;
	    int i,j,k;
	    vector <int> v;
	    for(i=0;i<=n-1;i++)
	    {
	    	if(s[i]=='*')
	    	{
	    		v.pb(i+1);
			}
		}
		int m=v.size();
		int pref[m];
		int suff[m];
		pref[0]=0;
		int ans=INF;
		for(i=1;i<=m-1;i++)
		{
			pref[i]=pref[i-1]+v[i-1];
		}
		suff[m-1]=0;
		for(i=m-2;i>=0;i--)
		{
			suff[i]=suff[i+1]+v[i+1];
		}
//		for(i=0;i<=m-1;i++) cout<<v[i]<<" ";
//		cout<<endl;
//		for(i=0;i<=m-1;i++) cout<<pref[i]<<" ";
//		cout<<endl;
//		for(i=0;i<=m-1;i++) cout<<suff[i]<<" ";
//		cout<<endl;
		for(i=0;i<=m-1;i++)
		{
			int x=suff[i]-v[i]*(m-i-1)-((m-i-1)*(m-i))/2;
			int y=v[i]*(i)-pref[i]-((i)*(i+1))/2;
			ans=min(ans,x+y);
		}
		if(ans==INF) cout<<0<<endl;
		else cout<<ans<<endl;
	}
   return 0;
}

```