On dividing x5−4x3+x2+3x+1 by polynomial g(x), the quotient and remainder are (x2−1) and 2 respectively. Find g(x).