First, simplify √18 by writing it as √(9x2) = √9 x √2 = 3√2.
Then, rationalise the denominator by multiplying both top and bottom of the fraction by √2.
This gives √2 x √2 = 2 in the denominator, and (3√2+10) x √2 = 3x2+10√2 in the numerator.
This can be simplified to 3+5√2 i.e. p=3, q=5