
// Problem : E. Arranging The Sheep
// Contest : Codeforces - Codeforces Round #719 (Div. 3)
// URL : https://codeforces.com/contest/1520/problem/E
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(container) container.begin(), container.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
const int mod = 1e9+7;

#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
//modular and binary exponentiation power Function
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;

        if(a>=p)
        a = a%p;

        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
// Function that convert Decimal to binary
vector<int>  decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    vector<int> v;
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            v.push_back(1);
        else
            v.push_back(0);
    }

    return v;
}

int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;

        // If the element is present at the middle
        // itself
        if (arr[mid] == x)
            return mid;

        // If element is smaller than mid, then
        // it can only be present in left subarray
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);

        // Else the element can only be present
        // in right subarray
        return binarySearch(arr, mid + 1, r, x);
    }

    // We reach here when element is not
    // present in array
    return -1;
}

int maxResult(int n, int a, int b, int c)
{
    int maxVal = 0;

    // i represents possible values of a * x
    for (int i = 0; i <= n; i += a)

        // j represents possible values of b * y
        for (int j = 0; j <= n - i; j += b) {
            float z = (float) (n - (i + j)) / c;


            // If z is an integer
            if (floor(z) == ceil(z)) {
                int x = i / a;
                int y = j / b;
                maxVal = max(maxVal, x + y + (int)z);

            }
        }

    return maxVal;
}

void SeiveOfEratosthenes(int n)
{
    bool prime[n+1];
    vector<int> v;

    memset(prime,true,sizeof(prime));

    for(int i=2;i*i<=n;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {
                prime[j] = false;
            }
        }
    }

    for(int i=2;i<=n;i++)
    {
        if(prime[i])
       {
           v.push_back(i);
       }
    }

}

//whenever you have to do modulo in division case use power(x,mod-2,mod);
//try to use the meaningful variables
//when constraints are of length 20 think of bitmasking (iterate over all subsets)

int gcd(int a, int b)
{
    if(a == 0)
        return b;
    return gcd(b % a, a);
}


void solve()
{
 int n;
 cin>>n;
 string s;
 cin>>s;
 vector<int> v;
 int cnt = 0;
 for(int i=0;i<n;i++){
 	if(s[i]=='*'){
 		v.pb(i-cnt);
 		cnt++;
 	}
 }
 
 if(v.size()<=1)
 cout<<"0";
 else{
 	int ans = 0;
 	int md = v[(v.size()-1)/2];
 	for(auto i : v){
 		ans += abs(i-md);
 	}
 	cout<<ans;
 }
 cout<<"\n";
 
}


int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
  cin>>t;
  while(t--)
  {
      solve();
  }
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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

// Problem : E. Arranging The Sheep
// Contest : Codeforces - Codeforces Round #719 (Div. 3)
// URL : https://codeforces.com/contest/1520/problem/E
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(container) container.begin(), container.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
const int mod = 1e9+7;

#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
//modular and binary exponentiation power Function
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;

        if(a>=p)
        a = a%p;

        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
// Function that convert Decimal to binary
vector<int>  decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    vector<int> v;
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            v.push_back(1);
        else
            v.push_back(0);
    }

    return v;
}

int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;

        // If the element is present at the middle
        // itself
        if (arr[mid] == x)
            return mid;

        // If element is smaller than mid, then
        // it can only be present in left subarray
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);

        // Else the element can only be present
        // in right subarray
        return binarySearch(arr, mid + 1, r, x);
    }

    // We reach here when element is not
    // present in array
    return -1;
}

int maxResult(int n, int a, int b, int c)
{
    int maxVal = 0;

    // i represents possible values of a * x
    for (int i = 0; i <= n; i += a)

        // j represents possible values of b * y
        for (int j = 0; j <= n - i; j += b) {
            float z = (float) (n - (i + j)) / c;


            // If z is an integer
            if (floor(z) == ceil(z)) {
                int x = i / a;
                int y = j / b;
                maxVal = max(maxVal, x + y + (int)z);

            }
        }

    return maxVal;
}

void SeiveOfEratosthenes(int n)
{
    bool prime[n+1];
    vector<int> v;

    memset(prime,true,sizeof(prime));

    for(int i=2;i*i<=n;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {
                prime[j] = false;
            }
        }
    }

    for(int i=2;i<=n;i++)
    {
        if(prime[i])
       {
           v.push_back(i);
       }
    }

}

//whenever you have to do modulo in division case use power(x,mod-2,mod);
//try to use the meaningful variables
//when constraints are of length 20 think of bitmasking (iterate over all subsets)

int gcd(int a, int b)
{
    if(a == 0)
        return b;
    return gcd(b % a, a);
}


void solve()
{
 int n;
 cin>>n;
 string s;
 cin>>s;
 vector<int> v;
 int cnt = 0;
 for(int i=0;i<n;i++){
 	if(s[i]=='*'){
 		v.pb(i-cnt);
 		cnt++;
 	}
 }
 
 if(v.size()<=1)
 cout<<"0";
 else{
 	int ans = 0;
 	int md = v[(v.size()-1)/2];
 	for(auto i : v){
 		ans += abs(i-md);
 	}
 	cout<<ans;
 }
 cout<<"\n";
 
}


int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
  cin>>t;
  while(t--)
  {
      solve();
  }
}

```