Given that p varies as the square of q and q varies inversely as the…