One way would be to set it up as a long division:
#color(white)("xxxxxxx")ul(color(white)("xx")-3x^2color(white)("x")-2xcolor(white)("xx")+7color(white)("xxxxxxxxxxxxx")#
#x^2+3" ) " -3x^4color(white)("x")-2x^3color(white)("x")-2x^2color(white)("x")-2xcolor(white)("x")+3#
#color(white)("xxxxxxxxx")ul(-3x^4color(white)("xxxxxxxx")-9x^2color(white)("xxxxxxxxxxx"))#
#color(white)("xxxxxxxxxxxxxxxx")-2x^3+7x^2color(white)("x")-2xcolor(white)("xx")+3#
#color(white)("xxxxxxxxxxxxxxxxx")ul(-2x^3color(white)("xxxxx")-6xcolor(white)("xxxxxxx"))#
#color(white)("xxxxxxxxxxxxxxxxxxxxxxx")7x^2color(white)("x")+4xcolor(white)("x")+3#
#color(white)("xxxxxxxxxxxxxxxxxxxxxxx")ul(7x^2color(white)("xxxxxx")+21#
#color(white)("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx")4xcolor(white)("x")-18#