\(P=\left(x^4+y^4-2x^2y^2+2x^2y^2\right)+\left(x+y\right)^3-3xy\left(x+y\right)-xy\left(x^2+y^2\right)+36xy\)
\(=\left(x^2+y^2\right)^2-2x^2y^2+27-9xy-xy\left(x^2+y^2\right)+36xy\)
\(=\left(x^2+y^2\right)\left(x^2+y^2-xy\right)-2x^2y^2+27+27xy\)
\(=\left[\left(x+y\right)^2-2xy\right]\left[\left(x+y\right)^2-2xy-xy\right]-2x^2y^2+27+27xy\)
\(=\left[9-2xy\right]\left[9-3xy\right]-2x^2y^2+27+27xy\)
\(=81-27xy-18xy+6x^2y^2-2x^2y^2+27+27xy\)
\(=108-18xy+4x^2y^2\)