def square_and_multiply(a: int, power: int, modulo: int) -> int:
    """
    Fast technique for exponentiation of a base to a power with a modulo
    :param a:
    :param power:
    :param modulo:
    :return:
    """
    result = 1

    while power > 0:
        if (power & 1) == 1:
            result = (result * a) % modulo

        power //= 2
        a = (a * a) % modulo

    return result