'''
keys: 
Solutions:
Similar:
T:
S:
'''
from typing import List



class Solution:
    # official
    def toGoatLatin1(self, S: str) -> str:
        def proc(idx, word):
            if word[0] not in 'aeiouAEIOU':
                word = word[1:] + word[0]

            return word + 'ma' + ('a' * idx)

        return ' '.join([proc(i, w) for i, w in enumerate(S.split(), 1)])
    
    # self-made; O(N^2) for S and T, worst case, N as length of S
    def toGoatLatin(self, S: str) -> str:
        letters = string.ascii_lowercase
        vowel = ["a", "e", "i", "o", "u"]
        consonant = [v for v in letters if v not in vowel]
        
        res = []
        words = S.split()
        for i, word in enumerate(words, 1):
            if word[0].lower() in vowel:
                word += "ma"
            elif word[0].lower() in consonant:
                word = word[1:] + word[0] + "ma"
            word += "a"*i
            res.append(word)
        return " ".join(res)
        