#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define error1(x) cerr<<#x<<" = "<<(x)<<endl
#define error2(a,b) cerr<<"("<<#a<<", "<<#b<<") = ("<<(a)<<", "<<(b)<<")\n";
#define coutall(v) for(auto &it: v) cout << it << " "; cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
const int inf = 1e9;
void solve() {
int n;
string s1, s2;
cin >> n >> s1;
s1 = '#' + s1; // 1'base
s2 = "aeiouaeiou";
map<char, short> mp = {{'a', 0}, {'e', 1}, {'i', 2}, {'o', 3}, {'u', 4}};
vector<vector<short>> pos(5);
for(short i = 0; i < s2.size(); i++) {
pos[mp[s2[i]]].pb(i);
}
auto cost = [&](short from, short to) -> short {
return *lower_bound(all(pos[to]), pos[from][0]) - pos[from][0];
};
vector<vector<vector<int>>> dp(6, vector<vector<int>> (33, vector<int> (n + 1, -1)));
auto rec = [&](auto&& self, int i, short back, bitset<5> &vis) -> int {
if(i > n) return 0;
int &ans = dp[back][vis.to_ulong()][i];
if(ans != -1) return ans;
ans = inf;
if(back != 5) ans = cost(mp[s1[i]], back) + self(self, i + 1, back, vis);
for(short ch = 0; ch < 5; ch++) {
if(vis[ch]) continue;
vis[ch] = 1;
ans = min(ans, cost(mp[s1[i]], ch) + self(self, i + 1, ch, vis));
vis[ch] = 0;
}
return ans;
};
bitset<5> vis = 0;
cout << rec(rec, 1, 5, vis) << endl;
return;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
int tc = 1;
cin >> tc;
for (int t = 1; t <= tc; t++) {
// cout << "Case " << t << ": ";
solve();
}
return 0;
}