Observe h(y)=y2+y−2=(y+2)(y−1). Thus both y+2 and y−1 are factors of both p(y) and q(y). Hence (y−1)(y+2) is a factor of p(y)=(y−1)(2y2+ay+2). This shows that (y+2) is a factor of 2y2+ay+2. We may write
2v+ay+2=(y+2)f(y)
for some polynomial f(y). Putting y=−2 in this, we obtain
2×(−2)2+2=0.
We obtain 10−2a=0. Hence a=5. Similarly (y−1)(y+2) is a factor of q(y)=(y+2)(3y2−by+1). This shows that y−1 is a factor of 3y2−by+1 and we may write
3y2−by+1=(y−1)g(y)
for some polynomial g(y). Taking y=1, we obtain
3×(1)2−b×(1)+1=0.
This gives 4−b=0. Hence b=4.
Thus a=5 and b=4.