g(q) = 145q -32890 - (1/286 q^2 + 29q)