from itertools import permutations
MOD = 1000000007
M = 2 * 10**5 + 10
cost = [[0] * 26 for _ in range(26)]
all_permutations = []
def precal():
vowel = "aeiou"
for i in range(len(vowel)):
l = i
cnt = 0
while cnt < 5:
cost[ord(vowel[i]) - ord('a')][ord(vowel[l]) - ord('a')] = cnt
l += 1
cnt += 1
if l == 5:
l = 0
all_permutations.append(vowel)
for perm in permutations(vowel):
all_permutations.append("".join(perm))
def solve():
t = 1
precal()
t= int(input())
for _ in range(t):
n = int(input())
s = input()
mx = MOD
for perm in all_permutations:
p = perm
dp = [[0] * 5 for _ in range(n + 1)]
for i in range(5):
for j in range(1, n + 1):
pro = cost[ord(s[j - 1]) - ord('a')][ord(p[i]) - ord('a')]
if i == 0:
dp[j][i] = dp[j - 1][i] + pro
else:
dp[j][i] = dp[j - 1][i] + pro
dp[j][i] = min(dp[j][i], dp[j][i - 1])
mx = min(mx, dp[n][i])
print(mx)
if __name__ == "__main__":
solve()