X^2Y-Y^2Z+Z^2X-X^2Z+Y^2X+Z^2Y-2XYZ
=X^2Y+Y^2X-Y^2Z+Z^2Y-XYZ+Z^2X-X^2Z-XYZ
=XY(X+Y)+YZ(Z-Y-X)+XZ(Z-X-Y)
=XY(X+Y)+Z(Z-X-Y)(X+Y)
=(X+Y)[XY+Z(Z-X-Y)]
=(X+Y)(XY+Z^2-ZX-ZY)
=(X+Y)(Z^2-ZX+XY-ZY)
=(X+Y)[Z(Z-X)+Y(X-Z)]
=(X+Y)(X-Z)(Y-Z)
X^2Y-Y^2Z+Z^2X-X^2Z+Y^2X+Z^2Y-2XYZ
=X^2Y+Y^2X-Y^2Z+Z^2Y-XYZ+Z^2X-X^2Z-XYZ
=XY(X+Y)+YZ(Z-Y-X)+XZ(Z-X-Y)
=XY(X+Y)+Z(Z-X-Y)(X+Y)
=(X+Y)[XY+Z(Z-X-Y)]
=(X+Y)(XY+Z^2-ZX-ZY)
=(X+Y)(Z^2-ZX+XY-ZY)
=(X+Y)[Z(Z-X)+Y(X-Z)]
=(X+Y)(X-Z)(Y-Z)