Let the polynomial be $P(x)$. It is given that for some polynomials $Q(x),Q_1(x)$
$$P(x)=(x^2+x+1)Q(x)+1-x$$
$$P(x)=(x^2-x+1)Q_1(x)+3x+5$$
Now it is well known that $x^2+x+1$ has the zeros as $\omega,\omega^2$ and $x^2-x+1$ has the zeroes $-\omega,-\omega^2$, where $\omega=\frac{-1+i\sqrt{3}}{2}$
So We get
$$P(\omega)=1-\omega$$
$$P(\omega^2)=1-\omega^2$$
$$P(-\omega)=3\omega+5$$
$$P(-\omega^2)=-3\omega^2+5$$
Now let us assume for some polynomial $Q_2(x)$ we have
$$P(x)=(x^4+x^2+1)Q_2(x)+Ax^3+Bx^2+Cx+D$$
Using the fact that $x^4+x^2+1$ has the zeros $\omega,\omega^2,-\omega,-\omega^2$ we get four linear equations as:
$$\left[\begin{array}{cccc}
1 & \omega^{2} & \omega & 1 \\
1 & \omega & \omega^{2} & 1 \\
-1 & \omega^{2} & -\omega & 1 \\
-1 & \omega & -\omega^{2} & 1
\end{array}\right]\left[\begin{array}{c}
A \\
B \\
C \\
D
\end{array}\right]=\left[\begin{array}{c}
1-\omega \\
1-\omega^{2} \\
5-3 \omega \\
5-3 \omega^{2}
\end{array}\right]$$
Now let us solve by Cramer's rule. The determinant of the matrix is $\Delta =12$,
$\Delta_1=-24$, $\Delta_2=24$, $\Delta_3=12$ and $\Delta_4=60$.
Thus the values of $A,B,C,D$ are
$$\begin{aligned}
&A=\frac{\Delta_{1}}{\Delta}=-2 \\
&B=\frac{\Delta_{2}}{\Delta}=2 \\
&C=\frac{\Delta_{3}}{\Delta}=1 \\
&D=\frac{\Delta_{4}}{\Delta}=5
\end{aligned}$$
So the required remainder is
$$-2x^3+2x^2+x+5$$