If Q = (all perfect squares less than 30) and P = (all odd numbers…