# Christina Kaddouh
# Bergen County Academies
# Junior Division

text_file = open("2jr_sampledata.txt", "r")
alphabet = ("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z").split()

def getLetter(list, x):
    for i in range(len(alphabet)):
        if list[x] == alphabet[i]:
            return i

def clearBlanks(list):
    for i in range(len(list)-1, -1, -1):
        if list[i] not in alphabet:
            del(list[i])

count = 1
for line in text_file:
    lineList = line.split()
    word1 = lineList[0]
    word2 = lineList[1]
    w1List = list(word1)
    w2List = list(word2)

    for i in range(len(w1List)-1):
        if w1List[i] == w1List[i+1] and w1List[i] not in ("A E I O U"):
            w1List[i+1] = ""
    clearBlanks(w1List)

    for i in range(len(w2List)-1):
        if w2List[i] == w2List[i+1] and w2List[i] not in ("A E I O U"):
            w2List[i+1] = ""
    clearBlanks(w2List)

    for i in range(1, len(w1List)):
        if w1List[i] in ("A E I O U") and i != 0:
            w1List[i] = ""
    clearBlanks(w1List)

    for i in range(1, len(w2List)):
        if w2List[i] in ("A E I O U") and i != 0:
            w2List[i] = ""
    clearBlanks(w2List)

    if len(w1List) >= len(w2List):
        checkWith = w2List
    else:
        checkWith = w1List

    for i in range(len(checkWith)):
        if w1List[i] == w2List[i]:
            w1List[i] = ""
            w2List[i] = ""
    clearBlanks(w1List)
    clearBlanks(w2List)

    for x in range(0, -1*(len(checkWith))-1, -1):
        if w1List[x] == w2List[x]:
            w1List[x] = ""
            w2List[x] = ""
    clearBlanks(w1List)
    clearBlanks(w2List)

    printString = ""

    if len(w1List) > len(w2List):
       printThis = w2List
       checkWith = w2List
    elif len(w2List) > len(w1List):
        printThis = w1List
        checkWith = w1List
    else:
        orderDict = {}
        for x in range(len(checkWith)):
            letter1 = getLetter(w1List, x)
            letter2 = getLetter(w2List, x)
            orderDict[letter1] = letter2

        for index in list(orderDict.keys()):
            if index > orderDict[index]:
                printThis = w2List
                break

            if index > orderDict[index]:
                printThis = w1List
                break

    for i in printThis:
        printString += i
    print("%d. %s" % (count, printString))
    count += 1