I agree with you on those two cases about value of P.
By checking there is no y such that |y^2 -9781| == 2, we can only be sure that
Pi1^e1*...Pim^em > 1? but we still need to prove:
(9781Pi1^c1*...Pim^cm-Pi1^d1*...Pim^dm) > 1 when Pi1^e1*...Pim^em = 2.
Notice that generally this might not be true, e.g. 9781 - 2^2*5*3*163 = 1. or 9781*2 - 31*631 =1. The good thing is in this problem, t1 + s1 = 2a1, ... tm + sm = 2am. How can you prove this in tight math? Thanks.