eval'P,Q,R,A,B,C='+$<.read.split*?,
r=[P*A,Q*B+=A,R*C+=B].min
l=[P*A-P,Q*B-Q,R*C-R].max+1
puts l>r ?-1:[l,r]*' '