def multi_powmod(bases, exponents, modulus):
    """
    raise all bases in xs to the respective powers in ys mod n:
    :math:`\prod_{i=1}^{len(bases)} base_i^{exponent_i} \pmod{modulus}`

    :param bases: the bases
    :param exponents: the exponents
    :param modulus: the modulus
    :return: the calculated result
    """
    if len(bases) != len(exponents):
        raise ValueError("xs and ys don't have the same size")
    result = 1
    for base, power in zip(bases, exponents):
        result = (result * pow(base, power, modulus)) % modulus
    return result