from collections import deque
from functools import cache


@cache
def func(z, w, div_z, add_x, add_y):
    result = z // div_z

    if z % 26 + add_x != w:
        result *= 26
        result += w + add_y

    return result


def solve(model_number):
    inputs = deque(map(int, str(model_number)))

    x = y = z = w = 0

    zs = [0]

    zs = {func(z, w, 1, 11, 14) for z in zs for w in [1]}
    print(1, len(zs), min(zs), max(zs))

    zs = {func(z, w, 1, 14, 6) for z in zs for w in [1]}
    print(2, len(zs), min(zs), max(zs))

    zs = {func(z, w, 1, 15, 6) for z in zs for w in [9]}
    print(3, len(zs), min(zs), max(zs))

    zs = {func(z, w, 1, 13, 13) for z in zs for w in [1]}
    print(4, len(zs), min(zs), max(zs))

    zs = {func(z, w, 26, -12, 8) for z in zs for w in [2]}
    print(5, len(zs), min(zs), max(zs))

    zs = {func(z, w, 1, 10, 8) for z in zs for w in [8]}
    print(6, len(zs), min(zs), max(zs))

    zs = {func(z, w, 26, -15, 7) for z in zs for w in [1]}
    print(7, len(zs), min(zs), max(zs))

    zs = {func(z, w, 1, 13, 10) for z in zs for w in [4]}
    print(8, len(zs), min(zs), max(zs))

    zs = {func(z, w, 1, 10, 8) for z in zs for w in [6]}
    print(9, len(zs), min(zs), max(zs))

    zs = {func(z, w, 26, -13, 12) for z in zs for w in [1]}
    print(10, len(zs), min(zs), max(zs))

    zs = {func(z, w, 26, -13, 10) for z in zs for w in [1]}
    print(11, len(zs), min(zs), max(zs))

    zs = {func(z, w, 26, -14, 8) for z in zs for w in [1]}
    print(12, len(zs), min(zs), max(zs))

    zs = {func(z, w, 26, -2, 8) for z in zs for w in [5]}
    print(13, len(zs), min(zs), max(zs))

    zs = {func(z, w, 26, -9, 7) for z in zs for w in [6]}
    print(14, len(zs), min(zs), max(zs))

    print("PASS" if 0 in zs else "FAIL")

    return z
