/**
* Problem Name: Vowel_arrangement
* Author: MJS
* Created: 12 December 2024, Thursday (13:02:07)...
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define nl '\n'
#define N 100003
string v="aeiou";
map<pair<char,char>,int> cost;
map<char,int> id;
int n;
string st;
vector<vector<vector<int>>> dp;
int f(int i,int j,char lst){
if(i==n) return 0;
int k=id[lst];
if(lst=='*') k=0;
else k++;
if(dp[i][j][k]!=-1) return dp[i][j][k];
int take=1e8,not_take=1e8;
int m1=j;
if(((1<<(id[st[i]]))&m1)==0){
if(lst!='*' && st[i]!=lst){
m1|=(1<<(id[lst]));
}
not_take=0+f(i+1,m1,st[i]);
}
for(auto &c: v){
int m2=j;
if(((1<<(id[c]))&m2)==0){
if(lst!='*' && c!=lst){
m2|=(1<<(id[lst]));
}
take=min(take,cost[{st[i],c}]+f(i+1,m2,c));
}
}
return dp[i][j][k]=min(take,not_take);
}
void answer_to_the_question(){
cin>>n>>st;
dp=vector(n+2,vector(33,vector(6,-1)));
cout<<f(0,0,'*')<<nl;
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(NULL);
int test_case; cin>>test_case;
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
cost[{v[i],v[j]}]=(10+j-i)%5;
}
}
for(int i=0;i<5;i++) id[v[i]]=i;
for(int MJS=1; MJS<=test_case; MJS++){
answer_to_the_question();
}
return 0;
}
// Hi..