Find the smallest positive integer $n, n>10$ such that $n+6$ is a prime and $9n+7$ is the square of an integer. The question seems fairly simple to understand. 
What I have tried is taking n as $6k+1$ and $6k-1$ in 2 separate cases. Then I took  $q=6(k+1)\pm 1$ and $9n+7=54k\pm9+7=r^2 \Rightarrow r^2=54k+16 $ or $54k-2$.
I am not able to proceed. The answer is given as 53. I am not looking for a solution involving trial and error. Any help would be greatly appreciated.
Thank you :)
 A: HINT.- $n+6=p$ and $9n+7=x^2$ implies $9p=x^2+47$. Thus $$p=\frac{x^2+2}{9}+5$$ The equation $x^2+2=9k$ admits the parameterization
$$\begin{cases}x=5-9t\\k=9t^2-10t+3\end{cases}$$ so $$k=2,19,54,107\cdots$$ Thus you can ended.
A: This involves a little trial and error, but first some ingenuity.
Module $9$, the square roots of $7$ are simply $\pm 4$.  Therefore, a square having the form $9n+7$ is also $(9k+4)^2$ where $k$ may be positive, negative or zero.  So
$9n+7=81k^2+72k+16$
$n=9k^2+8k+1$
To avoid divisibility by $2$ we must render $k$ even, and to avoid divisibility by $3$ we can't have $k\equiv 1\bmod 3$.  Among the remaining possibilities ($\in\{0,2\}\bmod 6$) we consider separately nonnegative values of $k$ and negative values of $k$.  For each separate group $n$ increases with the absolute value of $k$.
Nonnegative $k$:
$k=0\to n=1$, rejected, too small
$k=2\to n=53, n+6=59, 9n+7=22^2=484$, good.
Any solution for larger nonnegative $k$ will be larger and thus out of scope.  Now check that negative values of $k$ do not give any smaller solutions:
$k=-4\to n=113$, rejected, too large compared with the above.  (Also $n+6$ is composite.)
Therefore all absolutely larger negative candidates for $k$ are likewise out of scope.
By elimination $k=2, n=53$ wins.
