Bezout's Identity and Properties of Division

I need to write a proof for class and I'm having a lot of trouble getting started. Maybe someone here can help me.

**Problem:**

Let *a,m,n* be integers and *d*=gcd(*m,n*). If *m* divides *an* and *d* divides *a*, then *m* divides *a*^{2}.

(Is there a way to use LaTeX on this forum?)

**My Thoughts:**

I know we must use Bezout's Identity to solve this. So far I have that since d=gcd(m,n) and d|a, there exist integers r and s such that mr + ns = a.

That is all I have, and I really cannot for the life of me see what I'm supposed to do next. Does anybody see where I need to go from here?

Re: Bezout's Identity and Properties of Division

it looks like you're almost there:

consider amr + ans = a^{2}.

clearly m|amr and m|ans, since m|m, and m|an, thus m divides their sum.