#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() {
ll n;
string s1, s2;
cin >> n >> s1;
s2 = "aeiouaeiou";
map<char, int> mp = {{'a', 0}, {'e', 1}, {'i', 2}, {'o', 3}, {'u', 4}};
vector<vector<int>> pos(5);
for(int i = 0; i < s2.size(); i++) {
pos[mp[s2[i]]].pb(i);
}
vector<vector<int>> pre(5, vector<int> (n + 1, 0));
s1 = '#' + s1; // 1'base
for(int ch = 0; ch < 5; ch++) {
for(int i = 1; i <= n; i++) {
auto it = lower_bound(all(pos[ch]), pos[mp[s1[i]]][0]);
pre[ch][i] = pre[ch][i - 1] + (*it - pos[mp[s1[i]]][0]);
}
//cout << ch << " => "; coutall(pre[ch]);
}
vector<vector<int>> dp(33, vector<int> (n + 1, -1));
auto rec = [&](auto&& self, int i, bitset<5> &vis) -> int {
if(i > n) return 0;
int &ans = dp[vis.to_ullong()][i];
if(ans != -1) return ans;
ans = inf;
for(int ch = 0; ch < 5; ch++) {
if(vis[ch]) continue;
vis[ch] = 1;
for(int j = i; j <= n; j++) {
ans = min(ans, pre[ch][j] - pre[ch][i - 1] + self(self, j + 1, vis));
}
vis[ch] = 0;
}
return ans;
};
bitset<5> vis = 0;
cout << rec(rec, 1, vis) << endl;
return;
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;
}