
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,a,n) for(int i=a;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define input(a) fo(i , 0 , n)cin>>a[i];
#define pb push_back
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<ll, ll>	pii;
typedef vector<ll>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
const ll maxn = 1e5+6 ;
const ll MOD = 1e9 + 7  ;
vector<int> prim(1000005 , 1) ;
int fact[maxn] ;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
ll binomialCoeff(ll n, ll k){ll res = 1; if (k > n - k) k = n - k;for (ll i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1);}return res;}
 /*
int getmid(int l , int r){return (l+(r-l)/2) ;}
 struct segtree{
     int siz ;
     vi sums ;
    void init(int n){
       siz = 1 ;
       while(siz<n)siz*=2;
       sums.assign(2*siz , 0LL) ;
     }
     void set(int i , int v ,int cur , int l , int r){
         if(r-l==1){
           sums[cur] = v ;  return ;
         }
         int m = getmid(l , r) ;
         if(i < m){
            set(i , v , 2*cur+1 , l , m) ;
         }else set(i , v , 2*cur+2 , m , r) ;
         sums[cur] = sums[2*cur+1] + sums[2*cur+2] ;
      }
     void set(int i , int v){
        set(i , v ,0 , 0 , siz) ;
      }
      ll sum(int l , int r , int cur , int lx , int rx){
         if(lx>=r || l>=rx)return 0;
         if(lx>=l && rx<=r)return sums[cur] ;
         int mid  = getmid(lx , rx) ;
         ll s1 = sum(l , r , 2*cur+1 , lx , mid) ,s2 = sum(l , r , 2*cur+2 , mid , rx)  ;
         return s1 + s2 ;
       }
     ll sum(int l , int r){
         return sum(l , r , 0 ,  0 , siz) ;
       }
  };*/
 bool isVowel(char ch) {
    if(ch == 'a' || ch == 'i' || ch == 'e' || ch == 'u' || ch == 'o'){
        return true;
    }return false;
}
ll power(ll x, ll i,ll mod)
{
	ll ans = 1;
	while(i > 0)
	{
		if(i&1)
			ans = (ans*x)%mod;
		i >>=1;
		x = (x*x)%mod;
	}
	return ans;
}

ll modInverse(ll x, ll mod)
{
	return power(x , mod-2,mod);
}
int nCr (int n , int r) {
    if(n < r) {
        return 0;
    }
    return ( ( ( fact[n] * modInverse(fact[n-r], MOD) ) % MOD ) * modInverse(fact[r],MOD) ) % MOD;
}
ll power(int x, unsigned int y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

void erath(int n) {

    prim[1] = 0 ;
    prim[0] = 0 ;prim[2] = 1 ;
    for(int i=2 ; i*i<=n ; i++){
        if(prim[i]){
        for(int j=i*i ; j <=n ; j+=i){
            prim[j] = 0 ;
         }
        }
    }
  }
 ll gcd( ll a, ll b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

// Function to return LCM of two numbers
ll lcm(ll a, ll b)
{
    return (a / gcd(a, b)) * b;
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{                                                //functions hleps to sort vector of pair by second element ...pass it as third argu to sort function
    return (a.second < b.second);
}

ll n , m , k ;
int getmid(int l , int r){return (l+(r-l)/2) ;}
 struct segtree{
     int siz ;
     vpii sums ;
    void init(int n){
       siz = 1 ;
       while(siz<n)siz*=2;
       sums.assign(2*siz , {LONG_MAX , 0}) ;
     }
     void set(int i , int v ,int cur , int l , int r){
         if(r-l==1){
           sums[cur].first = v ;
           sums[cur].second = 1 ;
             return ;
         }
         int m = getmid(l , r) ;
         if(i < m){
            set(i , v , 2*cur+1 , l , m) ;
         }else set(i , v , 2*cur+2 , m , r) ;
         sums[cur].first = min(sums[2*cur+1].first  , sums[2*cur+2].first) ;
         if(sums[2*cur+1].first==sums[cur].first && sums[2*cur+2].first==sums[cur].first){
            sums[cur].second = sums[cur*2+1].second + sums[cur*2+2].second ;
         }else if(sums[2*cur+1].first==sums[cur].first){
            sums[cur].second = sums[cur*2+1].second;
         }else  {
           sums[cur].second = sums[cur*2+2].second;
          }
      }
     void set(int i , int v){
        set(i , v ,0 , 0 , siz) ;
      }
      pii sum(int l , int r , int cur , int lx , int rx){
         if(lx>=r || l>=rx)return {LONG_MAX , 0};
         if(lx>=l && rx<=r)return {sums[cur].first , sums[cur].second} ;
         int mid  = getmid(lx , rx) ;
         pii s1 = sum(l , r , 2*cur+1 , lx , mid) ,s2 = sum(l , r , 2*cur+2 , mid , rx)  ;
         if(s1.first < s2.first){
            return s1 ;
         }else if(s1.first > s2.first)return s2 ;
         else return {s1.first , s1.second+s2.second} ;
       }
     pii sum(int l , int r){
         return sum(l , r , 0 ,  0 , siz) ;
       }
  };
int nCrModp(int n, int r, int p)
{
    if (r > n - r)
        r = n - r;
    int C[r + 1];
    memset(C, 0, sizeof(C));

    C[0] = 1; // Top row of Pascal Triangle
    for (int i = 1; i <= n; i++) {
        for (int j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j - 1]) % p;
    }
    return C[r];
}

ll helper(vi nums, int k)
{

  ll midd = ((nums.size()+1)/2)-1 ;
  ll cen = nums[midd] ;
  ll res = 0 ;
  fo(i , 0 , nums.size()){
     res+= (abs(nums[midd] - nums[i] ) - abs(midd-i) ) ;
   }

   return res ;
}

void ans(){
   cin>>n;
   string s ;
   cin>>s;
   vi v ; k = 0 ;
   fo(i , 0 , n){
     if(s[i]=='*')v.pb(i), k++;
   }
   if(k<=1)cout<<0<<endl;
   else cout<<helper(v , n)<<endl;
 }

int main(){
   ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

   int t = 1 , opentest = 0;
    cin>>t;


	 if(opentest){in("input.txt"),out("output.txt");}
     else {
        while(t--)ans();
     }


    return 0;
}

### Prompt

Create a solution in cpp for 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>
using namespace std;
#define gc getchar_unlocked
#define fo(i,a,n) for(int i=a;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define input(a) fo(i , 0 , n)cin>>a[i];
#define pb push_back
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<ll, ll>	pii;
typedef vector<ll>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
const ll maxn = 1e5+6 ;
const ll MOD = 1e9 + 7  ;
vector<int> prim(1000005 , 1) ;
int fact[maxn] ;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
ll binomialCoeff(ll n, ll k){ll res = 1; if (k > n - k) k = n - k;for (ll i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1);}return res;}
 /*
int getmid(int l , int r){return (l+(r-l)/2) ;}
 struct segtree{
     int siz ;
     vi sums ;
    void init(int n){
       siz = 1 ;
       while(siz<n)siz*=2;
       sums.assign(2*siz , 0LL) ;
     }
     void set(int i , int v ,int cur , int l , int r){
         if(r-l==1){
           sums[cur] = v ;  return ;
         }
         int m = getmid(l , r) ;
         if(i < m){
            set(i , v , 2*cur+1 , l , m) ;
         }else set(i , v , 2*cur+2 , m , r) ;
         sums[cur] = sums[2*cur+1] + sums[2*cur+2] ;
      }
     void set(int i , int v){
        set(i , v ,0 , 0 , siz) ;
      }
      ll sum(int l , int r , int cur , int lx , int rx){
         if(lx>=r || l>=rx)return 0;
         if(lx>=l && rx<=r)return sums[cur] ;
         int mid  = getmid(lx , rx) ;
         ll s1 = sum(l , r , 2*cur+1 , lx , mid) ,s2 = sum(l , r , 2*cur+2 , mid , rx)  ;
         return s1 + s2 ;
       }
     ll sum(int l , int r){
         return sum(l , r , 0 ,  0 , siz) ;
       }
  };*/
 bool isVowel(char ch) {
    if(ch == 'a' || ch == 'i' || ch == 'e' || ch == 'u' || ch == 'o'){
        return true;
    }return false;
}
ll power(ll x, ll i,ll mod)
{
	ll ans = 1;
	while(i > 0)
	{
		if(i&1)
			ans = (ans*x)%mod;
		i >>=1;
		x = (x*x)%mod;
	}
	return ans;
}

ll modInverse(ll x, ll mod)
{
	return power(x , mod-2,mod);
}
int nCr (int n , int r) {
    if(n < r) {
        return 0;
    }
    return ( ( ( fact[n] * modInverse(fact[n-r], MOD) ) % MOD ) * modInverse(fact[r],MOD) ) % MOD;
}
ll power(int x, unsigned int y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

void erath(int n) {

    prim[1] = 0 ;
    prim[0] = 0 ;prim[2] = 1 ;
    for(int i=2 ; i*i<=n ; i++){
        if(prim[i]){
        for(int j=i*i ; j <=n ; j+=i){
            prim[j] = 0 ;
         }
        }
    }
  }
 ll gcd( ll a, ll b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

// Function to return LCM of two numbers
ll lcm(ll a, ll b)
{
    return (a / gcd(a, b)) * b;
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{                                                //functions hleps to sort vector of pair by second element ...pass it as third argu to sort function
    return (a.second < b.second);
}

ll n , m , k ;
int getmid(int l , int r){return (l+(r-l)/2) ;}
 struct segtree{
     int siz ;
     vpii sums ;
    void init(int n){
       siz = 1 ;
       while(siz<n)siz*=2;
       sums.assign(2*siz , {LONG_MAX , 0}) ;
     }
     void set(int i , int v ,int cur , int l , int r){
         if(r-l==1){
           sums[cur].first = v ;
           sums[cur].second = 1 ;
             return ;
         }
         int m = getmid(l , r) ;
         if(i < m){
            set(i , v , 2*cur+1 , l , m) ;
         }else set(i , v , 2*cur+2 , m , r) ;
         sums[cur].first = min(sums[2*cur+1].first  , sums[2*cur+2].first) ;
         if(sums[2*cur+1].first==sums[cur].first && sums[2*cur+2].first==sums[cur].first){
            sums[cur].second = sums[cur*2+1].second + sums[cur*2+2].second ;
         }else if(sums[2*cur+1].first==sums[cur].first){
            sums[cur].second = sums[cur*2+1].second;
         }else  {
           sums[cur].second = sums[cur*2+2].second;
          }
      }
     void set(int i , int v){
        set(i , v ,0 , 0 , siz) ;
      }
      pii sum(int l , int r , int cur , int lx , int rx){
         if(lx>=r || l>=rx)return {LONG_MAX , 0};
         if(lx>=l && rx<=r)return {sums[cur].first , sums[cur].second} ;
         int mid  = getmid(lx , rx) ;
         pii s1 = sum(l , r , 2*cur+1 , lx , mid) ,s2 = sum(l , r , 2*cur+2 , mid , rx)  ;
         if(s1.first < s2.first){
            return s1 ;
         }else if(s1.first > s2.first)return s2 ;
         else return {s1.first , s1.second+s2.second} ;
       }
     pii sum(int l , int r){
         return sum(l , r , 0 ,  0 , siz) ;
       }
  };
int nCrModp(int n, int r, int p)
{
    if (r > n - r)
        r = n - r;
    int C[r + 1];
    memset(C, 0, sizeof(C));

    C[0] = 1; // Top row of Pascal Triangle
    for (int i = 1; i <= n; i++) {
        for (int j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j - 1]) % p;
    }
    return C[r];
}

ll helper(vi nums, int k)
{

  ll midd = ((nums.size()+1)/2)-1 ;
  ll cen = nums[midd] ;
  ll res = 0 ;
  fo(i , 0 , nums.size()){
     res+= (abs(nums[midd] - nums[i] ) - abs(midd-i) ) ;
   }

   return res ;
}

void ans(){
   cin>>n;
   string s ;
   cin>>s;
   vi v ; k = 0 ;
   fo(i , 0 , n){
     if(s[i]=='*')v.pb(i), k++;
   }
   if(k<=1)cout<<0<<endl;
   else cout<<helper(v , n)<<endl;
 }

int main(){
   ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

   int t = 1 , opentest = 0;
    cin>>t;


	 if(opentest){in("input.txt"),out("output.txt");}
     else {
        while(t--)ans();
     }


    return 0;
}

```