The x and y intercepts of the unreflected ray are (p,0) and (0,q).
therefore the equation of the line(ray) before reflection is
(x/p) + (y/q) = 1
qx + py - pq = 0
now as the ray is getting reflected two times, first on the y-axis and then on the x-axis, the slope of the line remains unchanged.
therefore the equation of the line will become
qx + py + c = 0 where c is just a constant
now after the second reflection the x intercept of the line becomes (-p,0)
-pq + 0 + c = 0 therefore c = pq
therefore the equation of the second line becomes
qx + py + pq = 0