Help me in solving ST08 problem

My issue

I’m a bit confused about the substring that needs to be extracted, I had stored it in A. But I think the m value is not updated after the loop. Please help

My code

# Update the code below to solve the problem

t = int(input())
for i in range(t):
    S = input()
    
    count=0
    flag=0
    A=''
    
    for i in S:
        m=0
        A=A+i[m:m+2]
        for j in A:
            if(j==('a' or 'e' or 'i' or 'o' or 'u')):
                count+=1
            else:
                flag=1
            m=m+1
            
    if(count>2 and flag==0):
        print("Happy")
    elif(count<2 and flag==1):
        print("Sad")

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

@priyanka_021
Hi, u can implement it in this way too.

# Solution as follows

t = int(input())
for i in range(t):
    S = str(input())
    
    string_Length = len(S)
    i = 0
    flag = 0
    while i < (string_Length-2):
        #if any element is a vowel, and its next 2 elements are vowels, then our condition is met
        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')