Help me in solving ST08 problem

My issue

My code

# Update the code below to solve the problem

t = int(input())
for i in range(t):
    S = input()
    

Learning course: Python for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone

Update the code below to solve the problem

t = int(input())
for i in range(t):

S = str(input())
i = 1
flag= 0
s =len(S)
while i < s:
    
    if S[i] == "a" or S[i]== "e" or S[i]== "i" or S[i]== "o" or S[i]== "u":
        if S[i+1] == "a" or S[i+1] == "e" or S[i+1] == "i" or S[i+1] == "o" or S[i+1] == "u" :
            if S[i+2] == "a" or S[i+2] == "e" or S[i+2] == "i" or S[i+2] == "o" or S[i+2] == "u" :
                flag = 1
                break
            
    i = i+1
if flag == 1:
    print("Happy")

else:
    print("Sad")

Also the Solution was there to help …