# Devon Lai
# Bergen County Academies
# Junior Division

file = open("2jr_sampledata.txt", "r")

# Rule 1
for line in file:
    list = []
    remove = []
    line = line.strip()
    for char in line:
        list.append(char)
    for x in range(0, len(list)):
        if x != 0:
            if list[x] == list[x-1]:
                remove.append(x)
    number = 0
    for x in remove:
        x -= number
        del(list[x])
        number += 1

# Rule 2
    removal = []
    vowels = ["A", "E", "I", "O", "U"]
    for x in range(1, len(list)):
        if list[x] in vowels:
            removal.append(x)
    num = 0
    for x in removal:
        x -= num
        del(list[x])
        num += 1

# Rule 3
    string = ""
    for x in list:
        string += x
    thing = string.split(" ")
    word1 = []
    word2 = []
    for x in thing[0]:
        word1.append(x)
    for x in thing[1]:
        word2.append(x)
    if len(word1) > len(word2):
        length = len(word2)
    else:
        length = len(word1)
    anotherremove = []
    for x in range(length):
        if word1[x] == word2[x]:
            anotherremove.append(x)
    numb = 0
    for x in anotherremove:
        x -= numb
        del (word1[x])
        del (word2[x])
        numb += 1

# Rule 4
    word1.reverse()
    word2.reverse()
    if len(word1) > len(word2):
        length = len(word2)
    else:
        length = len(word1)
    anotherremove = []
    for x in range(length):
        if word1[x] == word2[x]:
            anotherremove.append(x)
    numb = 0
    for x in anotherremove:
        x -= numb
        del (word1[x])
        del (word2[x])
        numb += 1
    word1.reverse()
    word2.reverse()

    # Output
    strin = ""
    if len(word1) > len(word2):
        for x in word2:
            strin += x
        print(strin)
    elif len(word2) > len(word1):
        for x in word1:
            strin += x
        print(strin)
    else:
        biglist = []
        biglist.append(word1)
        biglist.append(word2)
        biglist.sort()
        for x in biglist[0]:
            strin += x
        print(strin)