Let $p$ be a prime number with $p \neq 2.$ Let $q = \frac {p-1} {2}$ and $u$ be an element of order $q$ modulo $p.$ Then show that there exists an integer $m$ such that $u^m \equiv -1 \pmod p$ if and only if $p \equiv 1\pmod 4.$
I tried it but failed to conclude. What I did is as follows. $$u^m \equiv -1\pmod p \implies u^{2m} \equiv 1\pmod p.$$ Hence $q\mid 2m.$ Which is same as saying $(p-1)\mid 4m.$ Now I got stuck. How do I proceed now? Any help will be warmly appreciated.
Thanks for your time.