Загрузка данных


from itertools import product

alf = 'АЕЛПРЬ'

num = 0

for w in product(alf, repeat=6):
    num += 1
    word = ''.join(w)

    if num % 2 == 1 and word[0] not in 'АЛ' and word.count('П') >= 2:
        print(num, word)
        break

from itertools import product

alf = 'ВИЛМОС'

num = 0
ans = 0

for w in product(alf, repeat=5):
    num += 1
    word = ''.join(w)

    if num % 2 == 1:
        if word[0] not in 'ОС':
            if word.count('В') == 1 and word.count('С') <= 1:
                ans = num

print(ans)