#include <bits/stdc++.h>

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	int t;
	h >> t;
	while(t--){
		int n;
		h >> n;
		string s;
		h >> s;
		int temp = count(all(s), '*');
		if (temp == 0 || temp == n){
			g << 0 << NL;
			continue;
		}
		vi pos;
		int cnt = 1;
		f(i, 1, n, 1){
			if (s[i] == s[i - 1])
				cnt++;
			else{
				if (s[i] == '.')
					pos.eb(cnt);
				else
					pos.eb(-cnt);
				cnt = 1;
			}
		}
		if (s[n - 1] == '*')
			pos.eb(cnt);
		else
			pos.eb(-cnt);
		vli sheep, left, right;
		left.eb(0);
		int fl = 0;
		fit(it, pos){
			if (*it > 0){
				fl = 1;
				sheep.eb(*it);
			}
			else if (fl == 1){
				left.eb(-(*it));
				right.eb(-(*it));
			}
		}
		cnt = sheep.size();
		if (right.size() == cnt)
			right[cnt - 1] = 0;
		else
			right.eb(0);
		vli sa(cnt), sar(cnt);
		sa[0] = sheep[0];
		sar[cnt - 1] = sheep[cnt - 1];
		f(i, 1, cnt, 1){
			sa[i] += sa[i - 1] + sheep[i];
			sar[cnt - 1 - i] += sar[cnt - i] + sheep[cnt - 1 - i];
		}
		vli lans(cnt), rans(cnt);
		f(i, 1, cnt, 1){
			lans[i] = sa[i - 1] * left[i];
			rans[cnt - 1 - i] = sar[cnt - i] * right[cnt - 1 - i];
		}
		f(i, 1, cnt, 1){
			lans[i] += lans[i - 1];
			rans[cnt - 1 - i] += rans[cnt - i];
		}
		vli ans(cnt);
//		cerr << cnt << NL;
		f(i, 0, cnt, 1)
			ans[i] = lans[i] + rans[i];
		g << *min_element(all(ans)) << NL;
	}

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


### Prompt

Generate 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 f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define NL '\n'
#define modn 1000000007
#define EPS 1e-9

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< lli > vli;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< bool > vb;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	#ifdef LOCAL_TEST
		ifstream h("in");
		ofstream g("out");
		clock_t z = clock();
	#else
		#define h cin
		#define g cout
	#endif//LOCAL_TEST

	int t;
	h >> t;
	while(t--){
		int n;
		h >> n;
		string s;
		h >> s;
		int temp = count(all(s), '*');
		if (temp == 0 || temp == n){
			g << 0 << NL;
			continue;
		}
		vi pos;
		int cnt = 1;
		f(i, 1, n, 1){
			if (s[i] == s[i - 1])
				cnt++;
			else{
				if (s[i] == '.')
					pos.eb(cnt);
				else
					pos.eb(-cnt);
				cnt = 1;
			}
		}
		if (s[n - 1] == '*')
			pos.eb(cnt);
		else
			pos.eb(-cnt);
		vli sheep, left, right;
		left.eb(0);
		int fl = 0;
		fit(it, pos){
			if (*it > 0){
				fl = 1;
				sheep.eb(*it);
			}
			else if (fl == 1){
				left.eb(-(*it));
				right.eb(-(*it));
			}
		}
		cnt = sheep.size();
		if (right.size() == cnt)
			right[cnt - 1] = 0;
		else
			right.eb(0);
		vli sa(cnt), sar(cnt);
		sa[0] = sheep[0];
		sar[cnt - 1] = sheep[cnt - 1];
		f(i, 1, cnt, 1){
			sa[i] += sa[i - 1] + sheep[i];
			sar[cnt - 1 - i] += sar[cnt - i] + sheep[cnt - 1 - i];
		}
		vli lans(cnt), rans(cnt);
		f(i, 1, cnt, 1){
			lans[i] = sa[i - 1] * left[i];
			rans[cnt - 1 - i] = sar[cnt - i] * right[cnt - 1 - i];
		}
		f(i, 1, cnt, 1){
			lans[i] += lans[i - 1];
			rans[cnt - 1 - i] += rans[cnt - i];
		}
		vli ans(cnt);
//		cerr << cnt << NL;
		f(i, 0, cnt, 1)
			ans[i] = lans[i] + rans[i];
		g << *min_element(all(ans)) << NL;
	}

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif//LOCAL_TEST
}


```