count=0
while True:
    count+=1
    if count>5:
        break
    word=input('Enter your Words: ')
    #word = 'AMISSISSIJPPI EMISSOURIXQWP'
    wordlist=word.split(' ')
    word1=wordlist[0]
    word2=wordlist[1]
    
    #print(word,wordlist,word1,word2)

    
    #1) Delete any double consonents
    deleter1=word1[0]
    for i in range(1,len(word1)):
        #print(i,word1[i], word1[i-1],deleter1)
        if word1[i]!=word1[i-1]:
            deleter1+= word1[i]
            #print(deleter1)
    deleter2=word2[0]
    for i in range(1,len(word2)):
        #print(i,word2[i], word2[i-1],deleter2)
        if word2[i]!=word2[i-1]:
            deleter2+= word2[i]
            #print(deleter2)
    #print('after deleting doubles: ',deleter1,deleter2)
            
    #2) Delete the Vowels
    vowel='AEIOU'
    letter1=deleter1[0]
    for i in range(1,len(deleter1)):
        
        if deleter1[i] not in vowel:
            letter1+= deleter1[i]
        else:
            continue
    #print(letter1)
    
    letter2=deleter2[0]
    for i in range(1,len(deleter2)):
        
        if deleter2[i] not in vowel:
            letter2+= deleter2[i]
        else:
            continue
    #print('after deleting the vowels: ',letter1,letter2)



    #3) Delete the Letters in the Matching place Left to Right
    cancel1=''
    cancel2=''
    for i in range(min(len(letter1),len(letter2))):
        #print(cancel1,cancel2,i, letter1[i],letter2[i])
        if letter1[i] != letter2[i]:
            cancel1 += letter1[i]
            cancel2 += letter2[i]
            
        else:
            continue
    cancel1 = cancel1+letter1[min(len(letter1),len(letter2)):]
    cancel2 = cancel2 +letter2[min(len(letter1),len(letter2)):]
    
    #print('after deleting from left to right',cancel1,cancel2)

    #4) Align to the right
    minlength=min(len(cancel1),len(cancel2))
    
    fin1=''
    fin2=''
    
    #print('minlength:', minlength, 'fin1:',fin1,'fin2:',fin2,'cancel1:',cancel1,'cancel2:',cancel2)
    
    for i in range(1,minlength+1):
        if cancel1[-i]!=cancel2[-i]:
            fin1= cancel1[-i] + fin1
            fin2= cancel2[-i] + fin2
        #print(i,cancel1[-i], cancel2[-i], fin1,fin2)       
        
    fin1=cancel1[:len(cancel1)-minlength] + fin1
    fin2= cancel2[:len(cancel2)-minlength] + fin2
    
        
    #print(cancel1,cancel2,fin1,fin2,)
        
                   
        
    #5)Take smeller word
    if len(fin1)>len(fin2):
        print(f'Output: {fin2}')
    elif len(fin2)> len(fin1):
        print(f'Output: {fin1}')
    else:
        print(f'Output:{min(fin1,fin2)}')