func_code_string: #pragma GCC target ( avx2 )   #pragma GCC optimize ( O3 )   #pragma GCC optimize ( unroll-loops )      #include<bits/stdc++.h>   using namespace std;      // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   // int rnd(int x, int y) {return (rng() % (y-x +1)) + x;};      #define ll long long   #define pb push_back   #define eb emplace_back   #define mp make_pair   #define lb lower_bound   #define ub upper_bound   #define ins insert   #define ull unsigned long long   #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))   #define ff first   #define ss second   #define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);   #define nl   n    #define sz(a) (int)(a).size()   #define all(a) (a).begin(),(a).end()   #define fl(a,x) memset(a,x,sizeof(a));   #define pt(a,x) cout << get<x>(a) <<     ;   #define mt make_tuple   #define vec vector   #define mxe max_element   #define mne max_element   #define present(c, x) (c.find(x) != c.end())   #define printall(a) for(auto i : a) cout << i <<     ; cout << nl ;      #define int long long      typedef vector<int> vii;   typedef vector<ll> vll;   typedef pair<int,int> pii;   typedef pair<ll,ll> pll;   typedef vector<pii> vpi;   typedef vector<pll> vpl;   typedef vector<vii> vvi;   typedef vector<vll> vvl;      #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(),  , ,    ); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }      void err(istream_iterator<string> it) {}   template<typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {       cout << *it <<   =   << a << endl;       err(++it, args...);   }      const int mod = (int) 1e9 + 7 ;   const int MOD = (int) 998244353 ;   const ll INF = (ll) 1e18;      inline int add(int a, int b) {return (a + b >= mod ? a + b - mod : a + b);}   inline int mul(int a, int b) {return (ll) a * b % mod ; }      void solve() {          int n; cin >> n ;       string s; cin >> s;        int ans = 0 ;        int id = 0 , cnt = 0 ;        int x = count(all(s),  * ) ;        rep(i,0,n) {           cnt += (s[i] ==  * ) ;            if(cnt == (x+1)/2) {               id = i ;                break ;           }       }       cnt = 0 ;        for(int i = id + 1 ; i < n ; ++i) {           if(s[i] !=  * ) continue ;            ans += i - id - 1 - cnt ;            ++cnt ;        }       cnt = 0 ;        for(int i = id - 1 ; i >= 0 ; --i) {           if(s[i] !=  * ) continue ;            ans += id - i - 1 - cnt ;            ++cnt ;        }       cout << ans << nl ;   }         int32_t main() {          fast;       int t; cin >> t ; rep(i,0,t)            solve() ;       // cout <<  Time elapsed:   << 1.0 * clock() / CLOCKS_PER_SEC <<   s. n ;       return 0;   }