/*
* Copyright (c) 2024 Emon Thakur
* All rights reserved.
*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using minheap = priority_queue<long long, vector<long long>, greater<long long>>;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
#define ll long long
#define ld long double
#define MOD 1000000007
#define pie 2*(acos(0.0))
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define endl '\n'
#define lcm(a,b) (a*b)/(__gcd<ll>(a,b))
#define print(v) for(auto e:v) cout<<e<<" "; cout<<endl;
#define printp(v) for(auto e:v) cout<<e.first<<" "<<e.second<<endl;
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define life_is_a_race ios::sync_with_stdio(false); cin.tie(nullptr);
map<pair<char,char>,int> tc;
unordered_map<char,int> indx;
string aeiou = "aeiou",s;
int n;
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 c1 = tc[{s[i],aeiou[last]}] + rec(i+1,mask|(1<<last),last);
int c2 = (aeiou[last]=='a' || (mask&(1<<indx['a']))==0)? tc[{s[i],'a'}] + rec(i+1,mask|(1<<indx['a']),indx['a'],dp): 1e7;
int c3 = (aeiou[last]=='e' || (mask&(1<<indx['e']))==0)? tc[{s[i],'e'}] + rec(i+1,mask|(1<<indx['e']),indx['e'],dp): 1e7;
int c4 = (aeiou[last]=='i' || (mask&(1<<indx['i']))==0)? tc[{s[i],'i'}] + rec(i+1,mask|(1<<indx['i']),indx['i'],dp): 1e7;
int c5 = (aeiou[last]=='o' || (mask&(1<<indx['o']))==0)? tc[{s[i],'o'}] + rec(i+1,mask|(1<<indx['o']),indx['o'],dp): 1e7;
int c6 = (aeiou[last]=='u' || (mask&(1<<indx['u']))==0)? tc[{s[i],'u'}] + rec(i+1,mask|(1<<indx['u']),indx['u'],dp): 1e7;
return dp[i][mask][last] = min({c2,c3,c4,c5,c6});
}
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);
}