Proving a function $\mathbb{Z}_m \to \mathbb{Z}_m,\ [a] \mapsto [a^2 + 3a + 1]$ is well defined 
Prove that $\operatorname{poly}\colon \mathbb{Z}_m \to \mathbb{Z}_m$ given by $\operatorname{poly}\colon [a] \mapsto [a^2 + 3a + 1]$ is well defined.


This is what I have so far, working in (mod m)
i.e. if $a' \equiv a$ then $a'^2+3a'+1 \equiv a^2 + 3a + 1$. ( need to prove)
Since $a' \equiv a$, there exists $d$ such that $dm = a' -a$
Not sure where to go from here, any tips?

Note that $(a^2+3a+1)-(a'^2+3a'+1)=(a-a')(a+a'+3)$. 
Thus, if $(a-a')$ is a multiple of $m$, then so is $(a^2+3a+1)-(a'^2+3a'+1)$.
