Clearly, \(p(x)\) has to be of the form \(p(x)=x^2+a x \pm 1\), where \(a\) is an integer. For \(a=\pm 1\) and \(a=0\), polynomial \(p\) has the required property: it suffices to take \(q=1\) and \(q=x+1\), respectively.

Suppose now that \(|a| \geq 2\). Then \(p(x)\) has two real roots, say \(x_1, x_2\), which are also roots of \(p(x) q(x)=x^n+a_{n-1} x^{n-1}+\cdots+a_0, a_i=\pm 1\). Thus

\[

1=\left|\frac{a_{n-1}}{x_i}+\cdots+\frac{a_0}{x_i^n}\right| \leq \frac{1}{\left|x_i\right|}+\cdots+\frac{1}{\left|x_i\right|^n}<\frac{1}{\left|x_i\right|-1},

\]

which implies \(\left|x_1\right|,\left|x_2\right|<2\). This immediately rules out the case \(|a| \geq 3\) and the polynomials \(p(x)=x^2 \pm 2 x-1\). The remaining two polynomials \(x^2 \pm 2 x+1\) satisfy the condition for \(q(x)=x \mp 1\).

Therefore, the polynomials \(p(x)\) with the desired property are \(x^2 \pm x \pm 1, x^2 \pm 1\), and \(x^2 \pm 2 x+1\)