/*
* Copyright (c) 2024 Emon Thakur
* All rights reserved.
*/
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define life_is_a_race ios::sync_with_stdio(false); cin.tie(nullptr);
//map<pair<char,char>,int> tc;
//unordered_map<char,int> indx;
int indx[256];
string aeiou = "aeiou",s;
int n,tc[256][256];
int rec(int i,int mask,int last,vector<vector<vector<int>>>&dp)
{
if(i==n) return 0;
if(dp[i][mask][last] != -1) return dp[i][mask][last];
int x = 10000000;
x = min(x,(aeiou[last]=='a' || (mask&(1<<indx['a']))==0)? tc[s[i]]['a'] + rec(i+1,mask|(1<<indx['a']),indx['a'],dp): 10000000);
x = min(x,(aeiou[last]=='e' || (mask&(1<<indx['e']))==0)? tc[s[i]]['e'] + rec(i+1,mask|(1<<indx['e']),indx['e'],dp): 10000000);
x = min(x,(aeiou[last]=='i' || (mask&(1<<indx['i']))==0)? tc[s[i]]['i'] + rec(i+1,mask|(1<<indx['i']),indx['i'],dp): 10000000);
x = min(x,(aeiou[last]=='o' || (mask&(1<<indx['o']))==0)? tc[s[i]]['o'] + rec(i+1,mask|(1<<indx['o']),indx['o'],dp): 10000000);
x = min(x,(aeiou[last]=='u' || (mask&(1<<indx['u']))==0)? tc[s[i]]['u'] + rec(i+1,mask|(1<<indx['u']),indx['u'],dp): 10000000);
return dp[i][mask][last] = x;
}
void solve(int tc)
{
cin >> n;
cin >> s;
vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(32,vector<int>(6,-1)));
cout<<rec(0,0,indx[s[0]],dp)<<endl;
}
int main()
{
life_is_a_race
tc['a']['e']=1; tc['a']['i']=2; tc['a']['o']=3; tc['a']['u']=4;
tc['e']['i']=1; tc['e']['o']=2; tc['e']['u']=3; tc['e']['a']=4;
tc['i']['o']=1; tc['i']['u']=2; tc['i']['a']=3; tc['i']['e']=4;
tc['o']['u']=1; tc['o']['a']=2; tc['o']['e']=3; tc['o']['i']=4;
tc['u']['a']=1; tc['u']['e']=2; tc['u']['i']=3; tc['u']['o']=4;
indx['a']=0; indx['e']=1; indx['i']=2; indx['o']=3; indx['u']=4;
int t=1;
cin>>t;
for(int i=1;i<=t;i++) solve(i);
}