def dumb_factor(x, primeset):
    """ If x can be factored over the primeset, return the
    set of pairs (p_i, a_i) such that x is the product
    of p_i to the power of a_i.
    If not, return []
    """
    factors = []
    for p in primeset:
        exponent = 0
        while x % p == 0:
            exponent = exponent + 1
            x = x//p
        if exponent > 0:
            factors.append((p,exponent))
    return factors if x == 1 else []