[r-36(p.q+q)/3] simplifies to [r-12q(p+1)] or [r-12pq-12q].
{n+r[r-36(p.q+q)/3]+p} therefore simplifies to {n+r[r-12pq-12q]+p}={n+r^2-12pqr-12qr+p}.
m{ ... } simplifies to mn+mr^2-12mpqr-12mqr+mp.
Finally, multiply by 3q/p:
3mnq/p+3mqr^2/p-36mq^2r-36mq^2r/p+3mq.