Transposition of a formula

Hello everyone,

I didn't know how to proceed with the following question:

Given $\displaystyle q = \sqrt{(5p^2 - 1)^2 -2}$ find $\displaystyle p$ in terms of $\displaystyle q$

I started off by squaring both sides, which I am pretty sure is the right thing to do, but I still can't figure out how to get p on its own on the left hand side.

In the back of the book the answer is $\displaystyle p = \sqrt{\frac{\sqrt{q^2 + 2} + 1}{5}}$

I tried to work backwards from this, but I still can't figure it out. Any help would be appreciated.

Regards,

evanator