#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif
using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
map<char,int> mp{
{'a', 0},
{'e', 1},
{'i', 2},
{'o', 3},
{'u', 4}
};
const int INF = 1e8;
void shelby() {
int n;
string s;
cin >> n >> s;
vector<int> v(n), cnt(5);
for (int i = 0; i < n; ++i) {
v[i] = mp[s[i]];
cnt[v[i]]++;
}
vector<int> perm(5);
iota(perm.begin(), perm.end(), 0LL);
int ans = LLONG_MAX;
auto calc = [&](int a, int b)-> int {
if (a < b) a += 5;
return a - b;
};
do {
int now = 0;
vector<vector<int> > pref(5, vector<int>(n, INF));
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < n; ++j) {
pref[i][j] = calc(perm[i], v[j]);
}
}
vector<vector<int> > memo(5, vector<int>(n, -1));
auto dp = [&](auto &&self, int i, int j)-> int {
if (j == n) return 0;
if (i == 5) return INF;
int &ret = memo[i][j];
if (~ret) return ret;
ret = INF;
ret = min(ret, pref[i][j] + min(self(self, i, j + 1), self(self, i + 1, j + 1)));
ret = min(ret, self(self, i + 1, j));
return ret;
};
debug(perm, pref);
ans = min(ans, dp(dp, 0, 0));
debug(ans);
} while (next_permutation(perm.begin(), perm.end()));
cout << ans << '\n';
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
cin >> t;
for (int _ = 1; _ <= t; ++_) {
// cout << "Case " << _ << ": ";
shelby();
}
}