#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define F first
#define S second
#define pii pair<int, int>
#define sz(x) (int) (x.size())
string tmp = "aeiou";
map<char, int> mp;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const int INF = 1e18 + 10;
int n; string s;
vector<vector<vector<int>>> dp;
int magic(int ind, int mask, int prv) {
if(ind == n) return 0;
int &ans = dp[ind][mask][prv];
if(~ans) return ans;
ans = INF;
for(int op = 0; op <= 4; op++) {
int cur = (mp[s[ind]] + op) % 5, f = (cur != prv);
if(f && (mask & (1LL << cur))) continue;
ans = min(ans, op + magic(ind + 1, mask | (1LL << cur), cur));
}
return ans;
}
void solve() {
cin>>n>>s;
dp = vector<vector<vector<int>>>(n, vector<vector<int>>(35, vector<int>(6, -1)));
cout<<magic(0, 0, 5)<<endl;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
mp['a'] = 0;
mp['e'] = 1;
mp['i'] = 2;
mp['o'] = 3;
mp['u'] = 4;
int t = 1; cin>>t;
for(int tc = 1; tc <= t; tc++) {
// cout<<"Case "<<tc<<":";
solve();
}
}