def checkNumber(i):
    if (i == '0'
            or i == '1'
            or i == '2'
            or i == '3'
            or i == '4'
            or i == '5'
            or i == '6'
            or i == '7'
            or i == '8'
            or i == '9'):
        return i
def openFile(fileName, ageArray = ['1', '9', None, None, ' ', 'r', '.']):
    with open(fileName, "r", encoding="utf-8") as file:
        for row in file:
            repCounter = 0
            counter = 0
            checkWord =[]
            for i in row:
                if counter != 2 and counter !=3:
                    if i == ageArray[counter]:
                        checkWord+=i
                        counter +=1
                    else:
                        checkWord = []
                        counter = 0
                    if counter == 7:
                            repCounter+=1
                            checkWord = []
                            counter = 0
                            if repCounter == 1:
                                print(row.strip())

                else:
                    if i==checkNumber(i):
                        checkWord+=i
                        counter+=1
                    else:
                        checkWord = []
                        counter = 0

print('---------------------SHAKESPEARE.EXP--------------------------------------')
openFile('polish_wiki_excerpt.exp')
print('----------------------SHAKESPEARE.EXP-----------------------------------')
openFile('polish_wiki_excerpt.in')
print('------------------------SIMPLE.IN------------------------------------')
openFile('simple.in')
print('-----------------------SIMPLE.EXP--------------------------------------')
openFile('simple.exp')