Finding the remainder of a polynomial divided by $x^4+x^2+1$ if remainders when dividing by $x^2+x+1$, $x^2-x+1$ are $-x+1$, $3x+5$. 
Find the remainder of $f$ divided by $g(x)=x^4+x^2+1$ if the remainder of $f$ divided by $h_1 (x)=x^2+x+1$ is $-x+1$ and the remainder of $f$ divided by $h_2(x)=x^2-x+1$ is $3x+5$.

My attempt was to write $f(x)=(x^4+x^2+1)q(x)+Ax^3+Bx^2+Cx+D=(x^2+x+1)(x^2-x+1)q(x)+Ax^3+Bx^2+Cx+D$ and then factor out $x^2+x+1$ to get $f(x)=(x^2+x+1)[(x^2-x+1)q(x)+B]+Ax^3+(C-B)x+(D-B)$, then do the same for $x^2-x+1$ and then use that along with the known remainder of $f$ divided by $x^2+x+1$ and $x^2-x+1$ to obtain $A$, $B$, $C$, $D$. However, $Ax^3$ is in the way so I don't know how to proceed nor do I have any other ideas to start with.

Let $u=x^2+x+1,$ $v=x^2-x+1$ so that $uv=x^4+x^2+1.$  Let $P$ be the given polynomial.
$$P=uq_1-x+1\tag1$$
$$P=vq_2+3x+5\tag2$$
$$P=uvq_3+R\tag3$$
There are polynomials $\lambda$ and $\mu$ such that
$$\lambda u+\mu v=1\tag4$$
Suitable values are $\lambda={-x+1\over2}$  and $\mu= {x+1\over2} .$
By (1), (2) and (4),
$$P=\lambda uP+\mu vP=\lambda uvq_2+(3x+5)\lambda u+\mu uvq_1+(-x+1)\mu v$$
Therefore, modulo $uv,$ $R$ is
$$ (3x+5)\lambda u+(-x+1)\mu v\tag5  $$
Of course, we must reduce the degree in (5).
$$(3x+5)\lambda=(3x+5){-x+1\over2}={1\over2}(-5x+8-3v)\tag6$$
$$(-x+1)\mu=(-x+1){x+1\over2}={1\over2}(x+2-u)\tag7$$
By (5), (6) and (7),
$$R={1\over2}\big((-5x+8)(x^2+x+1)+(x+2)(x^2-x+1) \big)$$
$$= {1\over2}\big((-5x^3+3x^2+3x+8)+(x^3+x^2-x+2) \big)$$
$$\text{Thus,}\ \ \ R=-2x^3+2x^2+x+5. $$
