def mod_exp(val, exp, modulus):
    """Computes an exponent in a modulus.

    Raises val to power exp in the modulus without overflowing.

    Args:
        val (int): Value we wish to raise the power of.
        exp (int): Exponent.
        modulus (int): Modulus where computation is performed.

    Returns:
        A value raised to a power in a modulus.
    """
    return pow(int(val), int(exp), int(modulus))