\(M=x^3+x^2y-2x^2-xy-y^2+3y+x+2017\)
\(\Rightarrow M=\left(x^3+x^2y-2x^2\right)-xy-y^2+2y+y+x-2+2019\)
\(\Rightarrow M=\left(x^3+x^2y-2x^2\right)-\left(xy+y^2-2y\right)+\left(y+x-2\right)+2019\)
\(\Rightarrow M=x^2\left(x+y-2\right)-y\left(x+y-2\right)+\left(x+y-2\right)+2019\)
\(\Rightarrow M=\left(x^2-y+1\right)\left(x+y-2\right)+2019\)
\(\Rightarrow M=\left(x^2-y+1\right).0+2019\)
\(\Rightarrow M=0+2019\)
\(\Rightarrow M=2019\)