(x2+x+2)2−(a−3)(x2+x+2)(x2+x+1)+(a−4)(x2+x+1)2=0
⇒(x2+x+2x2+x+1)2−(a−3)(x2+x+2x2+x+1)+(a−4)=0
Let x2+x+2x2+x+1=t>1
⇒t2−(a−3)t+(a−4)=0
⇒(t−1)(t−a+4)=0
t≠1, t=a−4
So, x2+x+2x2+x+1=a−4
⇒(a−5)x2+(a−5)x+(a−6)=0
Since x∈R,D≥0
⇒(a−5)2−4(a−5)(a−6)≥0⇒5<a≤193
p=5,q=19,r=3
p+q+r=5+19+3=27