There is a very simple approach here; just make sure you will assess the special cases, which are very small numbers.
Case $1$: The prime is of the form $p=9k+2$, then:
$$\frac{\frac{4p+1}{9} \times 9-1}{p}.$$
Case $2$: The prime is of the form $p=9k+4$, then:
$$\frac{\frac{2p+1}{9} \times 9-1}{p}.$$
Case $3$: The prime is of the form $p=9k+8$, then:
$$\frac{\frac{p+1}{9} \times 9-1}{p}.$$
Case $4$: The prime is of the form $p=9k+5$, then:
$$\frac{\frac{7p+1}{18} \times 18-1}{p}.$$
Case $5$: The prime is of the form $p=9k+7$, then:
$$\frac{\frac{5p+1}{18} \times 18-1}{p}.$$
Case $6$: The prime is of the form $p=9k+1$, then:
$$\frac{2k \times (\frac{9k}{2}-4)-1}{9k+1}.$$
PS: How was the answer developed?
Since $ab$ must be of the form $np+1$ for some $n \in \mathbb N$ it's worth investigating the cases where $n=1,2,3,4$. Here is the point where the idea of module $9$ appears simply because $2\times 4 <9$. Then, finding the constants $9$ and $18$ is not a big deal. The tricky part is Case $6$, which can be investigated in the most natural way as follows:
$$ab-1=n(9k+1) \implies a=\frac{9nk+n+1}{b} \implies \\ b<\frac{9k+1}{2}, \\ a=\frac{9nk+n+1}{b} < \frac{9k+1}{2}.$$
Hence, we must have:
$$\frac{9k+1}{2} >b> 2n, \\ b \mid 9nk+n+1.$$
At this point, assuming $b=2k$ gives us the fact that we must have:
$$b \mid kn+n+1,$$
such that $n \leq k-1.$
Now, putting $n=k-1$, just as a guess, leads to:
$$2k \mid k^2,$$
which is trivially true because $k$ was initially even because $9k+1$ is supposed to be a prime.
Best Answer
For all prime $p, q$ we have $$(p-1)^3>p^3-5p-18p = q^9-7q \geq (q^3-1)^3$$ so we have $$\boxed{p\geq q^3+1}$$
Simillary we have, for $p>29$: $$(p-2)^3 < p^3-5p^2-18p<q^9$$
so $$\boxed{p-1\leq q^3}$$
This means that for $p>29$ we have $p=q^3+1$ which means $q$ is even and thus impossibile.
Now if $p\leq 29$. Since $p\geq q^3+1$ we get $q=2$ or $3$...