Proof using Rolle's theorem

Let $g:\mathbf{R\rightarrow R}$ be a twice differentiable function.

We are supposed to prove that:

If $a_1 < a_2 < a_3$ and $g(a_1)=g(a_2)=g(a_3)=0$, prove that there exists a point $q \in (a_1,a_3)$ such that $g''(q)=0$.

I have an idea that this is supposed to be done using Rolle's theorem, but I don't know how to formulate a proof for this rigorously.

I would really appreciate if someone could explain to me why and how such a point would exist. I don't quite see it as a direct corollary of Rolle's Theorem.

HINT: There are points $b_1\in (a_1,a_2)$ and $b_2\in (a_2,a_3)$ with $g'(b_i)=0$.