def poly_eval(coefs, x):
    """
    Evaluates the polynomial whose coefficients are given in coefs on the value x.
    Polynomial coefficient are stored in coefs from the lowest power to the highest.
    x is required to be a ring element.
    """
    out = 0
    for i in range(len(coefs)):
        out = coefs[i] * (x ** i) + out
    return out