Using the work-rate formula (not sure whether it’s taught explicitly here). notice that

\frac{1}{p} + \frac{1}{r} + \frac{1}{t} = \frac{1}{5}

and that

\frac{1}{p} + \frac{1}{r} = \frac{1}{7}

Substituting the second to the first,

\frac{1}{7} + \frac{1}{t} = \frac{1}{5}

Simplifying,

\frac{1}{t} = \frac{1}{5} - \frac{1}{7} = \frac{2}{35}

t = \frac{35}{2} = 17.5 \text{ hours}

Thanks for the answer