\Big |\Big \{ \x\in [1,p^k]^3 : p^k| N\Big (\sum_{i=1}^3x_i\nu_i\Big )\Big \}\Big |\ll k p^{11k/4}.
\end{equation*}
\end{enumerate}
\end{lmm}
\begin{proof} The first four assertions are essentially given by \cite[Lemma 7.7]{May15b}, except that they work with a basis $\nu_1,\nu_2,\nu_3,\nu_4$ in place of $1,\theta ,\theta^2,\theta^3$ which has a negligible effect on the proof. Indeed, by \eqref{basew}  the $\Q$-vector space spanned by $\nu_1, \nu_2,\nu_3$ is the same
as the one spanned by $\omega_1,\omega _2,\omega_3$, and the change-of-basis matrix between the basis $\nu_1,\nu_2,\nu_3,\nu_4$ and $\omega_1,\omega_2,\omega_3,\omega_4$ has determinant $W$. Thus when $(N(\gd ),W)=1$ we have
$$\varrho_\v (\gd )=\frac{|\{\a\in [1,N(\gd )^3] : \gd | (a_1\omega_1+a_2\omega_2+a_3\omega_3)\}|}{N(\gd)^2},$$
and so it is sufficient to prove these four statements with the basis $\w$ in place of $\v$. The proof is then the same as in [14].

We are left to establish assertion 5. Since $N(\nu_1)\ne 0$, for any choice of $x_2,x_3$, $g_{x_2,x_3}(x_1):=N(x_1\nu_1+x_2\nu_2+x_3\nu_3)$ is a non-zero polynomial of degree 4 in $x_1$. Thus, given $x_2,x_3$, if $N(x_1\nu_1+x_2\nu_2+x_3\nu_3)\equiv 0\Mod{p^k}$, we see that $\|x_1-\alpha\|_p\ll p^{-k/4}$ for one of the 4 roots $\alpha$ of $g_{x_2,x_3}$ over $\overline{\Q_p}$. Thus there are $O(p^{3k/4})$ choices of $x_1\in[1,p^k]$ for each choice of $x_2,x_3$. This gives the result.
\end{proof}

%The proof uses Perron's formula and   the Dedekind zeta function $\zeta_K$.

Let $\gamma_K$ be the residue in $s=1$ of $\zeta_K$ and we define $\Sft$ to be the Euler product\footnote{This definition of $\Sft$ is slightly different as the one given in [14]. In the present paper $\Sft$ doesn't depend on some modulus $q^*$ or $m$.}
\begin{equation}
\Sft :=\prod_\gP \Big ( 1-\frac{\varrho_\v (\gP)}{N(\gP)}\Big )\Big ( 1-\frac{1}{N(\gP)}\Big )^{-1}.\label{eq:SingularDef}
\end{equation}
\begin{lmm}\label{Perron}There exists a constant $c>0$ such that
for  any ideal $\gI$ of $\cO_K$, $m\in\N$, $R\ge 2$ we have
\begin{equation*}
\sum_{\substack{{N(\gd)<R}\\ {(\gd ,\gI)=1}\\ {(N(\gd),m)=1}}} \frac{\mu (\gd )\varrho_\v (\gd)}{N(\gd )}\log \frac{ R}{N(\gd )}
=\frac{\Sft}{\gamma_K}\prod_{\gP | (m)\gI}\Big ( 1-\frac{\varrho _\v (\gP)}{N(\gP)}\Big )^{-1}+O\Big ( 2^{4\omega (\gI)}\exp (-c\sqrt{\log R})\Big ).
\end{equation*}
\end{lmm}
\begin{proof}
The proof is exactly the same as in \cite[Lemma 8.5]{May15b}. \cite[Lemma 8.5]{May15b} states the result with $N(J)^{o(1)}$ in place of $2^{4\omega(J)}$, but following the proof we see that the error term can be taken as $\exp (-c\sqrt{\log R})\prod_{\gP|J}( 1-\frac{1}{N (\gP)^{3/4}})^{-1}$, which is clearly sufficient for our slightly stronger bound.
\end{proof}
\begin{lmm}
\label{rhodrhoI}
For any $2\le R\le x$ we have
\begin{equation*}
\sum_{N(\gd )\le R}\mu^2 (\gd)\sum_{N(\gI)\le x}\frac{\rho_v (\gd \gI)}{N(\gd\gI)}\ll (\log x)^8.
\end{equation*}
\end{lmm}
\begin{proof}
By Rankin's trick, we have
\[
\sum_{N(\gd )\le R}\mu^2 (\gd)\sum_{N(\gI)\le x}\frac{\rho_v (\gd \gI)}{N(\gd\gI)}\le \prod_{N(\gP)\le x}\Bigl(1+2\sum_{k\ge 1}\frac{\varrho_\v (\gP^k)}{N(\gP^k)}\Bigr).
\]
By Lemma  \ref{rhov}, if $\gP$ is a degree 1 prime ideal above $p$ then the term in parentheses is $1+2/p+O(1/p^2)$, and if $\gP$ is of degree more than 1 above $p$ then this is $1+O(1/p^2)$. The result now follows from the Prime Ideal Theorem.
\end{proof}

\subsection{Multiplication in $\cO_\v$}
\begin{dfntn}\label{mult}
For any vectors $\bd, \be \in\Z^4\setminus\{\zero\}$, we define $\bd\diamond\be$  as be the vector
$\b\in\Q^4$ such that
\begin{equation*}
\sum_{i=1}^4b_i\nu_i=\sum_{i=1}^4 d_i\nu_i\times \sum_{i=1}^4 e_i\nu_i
\end{equation*}
For $1\le i\le 4$ we denote by $(\bd\diamond\be)_i$ the coordinate $b_i$.
\end{dfntn}
This operation is helpful to detect the elements of $\cO_\v$ with a fourth coordinate equal to zero.
The following lemma turns the problem of detecting this zero coordinate into a question about lattices.
\begin{lmm}\label{de40}
For any $\bd\in\Z^4\setminus\{ \zero\}$
let $\Lambda_\bd$ be the subset of $\Z^4$ defined by
\begin{equation*}
\Lambda_\bd =\{ \be\in\Z^4 : (\bd\diamond\be )_4=0\}.
\end{equation*}
Then $\Lambda_\bd$ is a lattice of rank $3$ and $\det (\Lambda _\bd)\asymp \| \bd\|/D $,where $D$ is the GCD of the components of $\bd$.
\end{lmm}
\begin{proof}
The argument is essentially a special case of \cite[Lemma 7.2]{May15b} .
We will expose it in a more pedestrian way. For all $1\le i,j\le 4$ there exist rational numbers $\lambda_{i,j,k}$, $1\le k\le 4$ such that
\begin{equation*}
\nu_i\nu_j=\sum_{k=1}^4\lambda_{ijk}\nu_k.
\end{equation*}
For all $\bd ,\be\in\Z^4$,
\begin{equation*}
\sum_{i=1}^4(\bd\diamond\be)_i\nu_i=\sum_{k=1}^4\Big (\sum_{i,j=1}^4\lambda_{ijk}d_ie_j\Big )\nu_k
\end{equation*}
Identifying the fourth coordinate, we deduce for all  $\bd\in\Z^4\setminus\{\zero\}$,
\begin{equation*}
\Lambda_\bd =\Big \{ \be\in\Z^4 :
\sum_{j=1}^4\Big (\sum_{i=1}^4 \lambda_{ij4}d_i\Big )e_j=0\Big \}.
\end{equation*}
The terms $\sum_{i=1}^4 \lambda_{ij4}d_i$, for $j=1,2,3,4$ correspond to the coefficients of the fourth row of the matrix
in basis $\v$
of the multiplication by $d=d_1\nu_1+d_2\nu_2+d_3\nu_3+d_4\nu_4$.
Since $\bd\not =\zero$, this matrix is invertible  and at least one of these coefficients is non zero.
This shows that $\Lambda_\bd$ has rank $3$.
By [7], the determinant of $\Lambda_\d$ is equal to the determinant of the dual lattice  that is for us the lattice spanned by the vector \begin{equation}\label{defT}T(\bd):=
\begin{pmatrix}
\sum_{i=1}^4 \lambda_{i14}d_i\\
\sum_{i=1}^4 \lambda_{i24}d_i\\
\sum_{i=1}^4 \lambda_{i34}d_i\\
\sum_{i=1}^4 \lambda_{i44}d_i\\
\end{pmatrix}.
\end{equation}
Since the components of this vector have size $O(\max_{1\le i\le 4}|d_i|)$, $\det (\Lambda_d)\ll \|\bd \|$.
\end{proof}

\medskip

\begin{lmm}\label{div}
For any $m\in\N$ and $X\ge 3$, we have
\begin{equation*}
\sum_{\max (|x_1|,|x_2|,|x_3|)\ll X}
\tau\Big (\sum_{i=1}^3 x_i\nu_i\Big )^m\ll X^3(\log X )^{O_m(1)}.
\end{equation*}
\end{lmm}
\begin{proof}
The proof is the same as that of \cite[Lemma 4.2]{May15b} which concerns the case $\nu_i=\theta^{i-1}$.
The only place where this change could have an importance is for the bound of the sums  with any $\gd$ such that $N(\gd )\ll X^{1/n}$
\begin{equation*}
\sum_{\substack{{\max (|x_1|,|x_2|,|x_3|)\ll X}\\ {\gd|(\sum_{i=1}^3x_i\nu_i)}}}1.
\end{equation*}
Since the $\nu_i$ are linear combinations of some $\theta^{j}$, $j=0,1,2,3$ for $\theta$ such that $K=\Q (\theta )$,
the condition $\gd |  (\sum_{i=1}^3x_i\nu_i)$ can be split in the $x_i$ into arithmetic progression $\Mod {N(\gd )}$,
and thus the argument of [14] combined with Lemma \ref{rhov} apply also in our case.
\end{proof}
\begin{lmm} Let $\bd\in\Z^4\setminus\{\zero\}\cap [-D,D]^4$ and
$\Lambda_\bd$ as in Lemma \ref{de40}.  Let $\z_1 (\bd)$ denote a shortest non-zero vector in $\Lambda_\bd$. Then we have $\|\z_1 (\bd )
\| \ll D^{1/3}$ and
\begin{equation*}
|\{ \bd\in [1,D]^n : \| \z_1 (\bd )\| \le Z\}|\ll D^{3+o( 1)}Z^3.
\end{equation*}
Furthermore we have
\begin{equation*}
\sum_{\| \bd\|\le D}\frac{1}{\| \z _1 (\bd )\| ^2}\ll D^{10/3 +o(1)}.
\end{equation*}
\end{lmm}
\begin{proof}
The proof is exactly the same as the proof of \cite[Lemma 7.3]{May15b} except that we have a slightly different definition for $\diamond$, and so require Lemmas \ref{de40} and \ref{div} instead of \cite[Lemma 4.2]{May15b} and \cite[Lemma 7.2]{May15b}.
\end{proof}
\begin{lmm}\label{WTI}
Let $\gd$ be an ideal of $\cO_K$ with $(N(\gd) ,q)=1$. Let $\cR\subset [-X,X]^3$ as in the Proposition \ref{prpstn:TypeI} below.
Then we have
\begin{equation*}
|\big \{ \a\in\Z^3\cap\cR:\gd |\big (\sum_{i=1}^3 a_i\nu_i\big ),\ \a\equiv\a_0\Mod q\}|=\frac{\varrho_\v (\gd )\vol (\cR)}{N(\gd)q^3}+O(N(\gd )^4X^2).
\end{equation*}
\end{lmm}
\begin{proof}
The proof is identical as the proof of \cite[Lemma 7.4]{May15b} with $\v$ in place of $(1,\ldots ,\theta ^{n-1})$. In fact,  the arguments of [14] give a slightly stronger error term of $O(X^2\varrho_\v(N(\delta)(qN(\delta))^{-2}+\varrho_\v (N(\delta )))$.
\end{proof}
\subsection{Sums of Type I}
We now state  a similar result to \cite[Proposition 7.5]{May15b}
\begin{prpstn}\label{prpstn:TypeI}
Let $\cR\subset [-X,X]^3$ be a region such that any line  parallel to the coordinate axes intersects $\cR$ in $O(1)$ intervals.
For any given $\u_0\in\Z^3$  and $q\le\sqrt{X}$ we define
\begin{equation*}
\Gamma =\Big \{ \sum_{i=1}^3 a_i\nu_i : \a\in\Z^3\cap\cR,\ \a\equiv\u_0\Mod q\Big \}.
\end{equation*}

Let $\Gamma_\gd=\{ \kappa\in\Gamma : \gd |(\kappa)\}$.
Then we have
\begin{equation}\label{STI}
\sum_{\substack{{N(\gd)\in [D,2D]}\\{(N(\gd ),q)=1}}}\Bigg | |\Gamma_\gd |-\frac{\varrho_\v (\gd)\vol (\cR)}{q^3N(\gd )}\Bigg |\ll
\end{equation}
\end{prpstn}
\begin{proof} We follow the proof of \cite[Proposition 7.5]{May15b}, but now  we work with a general order $\cO_\v$ in place of $\Z [\theta]$. This involves minor modifications at the beginning of the argument; the last steps require no modification. For brevity we emphasise just the key points requiring modification and only sketch the rest of th argument.

We split the summation on the ideals $\gd$ according to their class in $Cl_K$.
Let $\cC$ be a given class and consider the contribution of all the $\gd\in\cC$.
Since the $\gd$ in the summation in \eqref{STI} are coprime with $q$,
we can fix a representative integral ideal $\gc\in \cC$ such that $(N(\gc ),q)=1$ and with $N(\gc )=q^{o(1)}$.
The ideal $\gd\gc^{-1}(N(\gc))$ is a principal ideal of $\cO_K$. By Lemma \ref{Wsg} we can find a generator
of the form $\delta=\frac{1}{W}\sum_{i=1}^4d_i\nu_i$ where the $d_i$ are integers such that
$|d_i|\ll D^{1/n}q^{o(1)}$. Then $\delta_\gc:=\frac{1}{W N(\gc)}\sum_{i=1}^4d_i\nu_i$ is a generator of the principal fractional ideal $\gd\gc^{-1}$. In [14] it is proved that $|\sigma_0(\delta_\gc)|\gg D^{1/4}q^{o(1)}$ for all embeddings $\sigma_0$.

Let $\alpha\in\Gamma_\gd$, so $(\alpha)=\ga'\gd$ for some integral ideal $\ga '$. Since $(\alpha )=\ga '\gc\gd\gc^{-1}$ and $(\alpha )$ and $\gd\gc^{-1}=(\delta_\gc)$ are principal, $\ga '\gc$ is principal too, so
$\ga'\gc=(\beta )$ for some generator $\beta\in\cO_K$.
By Lemma \ref{coordinates}, we can take $\beta=\frac{1}{W}\sum_{i=1}^4b_i\nu_i$ where $\b =(b_1,b_2,b_3,b_4)\in\Z^4$ satisfies
$(\b \Mod W) \in \cV_0$. Then $(\alpha)=(\beta )(\delta_\gc)$.
Let $\bd =(d_1,d_2,d_3,d_4)$. We have $W^2N(\gc) \beta\delta_\gc=\sum_{k=1}^4(\bd\diamond \b)_k\nu_k$.
\begin{equation*}
\beta\delta_\gc=\sum_{k=1}^4\frac{1}{W^2N(\gc )}\Big (\sum_{i,j=1}^4\ell_{i,j,k}b_id_i\Big )\nu_k.
\end{equation*}
The coefficient of $\nu_i$ are integers if and only  $b_1,b_2,b_3,b_4$ satisfy some congruences modulo $W^2N(\gc)$.
We also need to impose that $\gc | (\beta)$. This is also equivalent to some congruences conditions modulo $W^2 N(\gc)$ for $b_1,b_2,b_3,b_4$.
Let $q_1=[q,W^2N(\gc)]$ and $\cV_0'\subset \{ 0\ldots , q_1-1\}^4$ the set of r classes satisfying all these conditions and furthermore such that
\begin{equation*}
(\d\diamond\b )_4 \equiv 0\Mod{q_1}\ \text{and}\ \frac{(\d\diamond\b)_i}{W^2N(\gc)}\equiv {(\u_0)_i}\Mod q\ \text{for}\
1\le i\le 3.
\end{equation*}
Thus, for $\gd\in\cC$, we are interested in
\begin{equation*}
|\Gamma_\gd |=\sum_{\b_0\in V_0'}\sum_{\substack{{\b\in\Z^4}\\ {\b\equiv\b_0\Mod {q_1}}\\ {\delta_\gc \beta\in \Gamma}}}1.
\end{equation*}
The rest of the proof follows [14].  Let $\Lambda _\d$ be the lattice introduced in Lemma \ref{de40}.
We write $\b=\b ^{(1)}+q_1\b^{(2)}$ where $\b^{(1)}$ is some vector of $\Lambda_{\d}$ such that
$\b^{(1)}\equiv \b_0\Mod {q_1}$ (when such $\b^{(1)}$ exists) and $\b^{(2)}\in\Lambda_{\gd_\gc}$
\begin{equation*}
|\Gamma_\gd |=\sideset{}{''}{\sum}_{\b_0\in V_0'}{}\sum_{\substack{{\b^{(2)}\in\Lambda_\d}\\ {\b\equiv\b_0\Mod {q_1}}\\ {\delta_\gc \beta_1+
q_1\delta_\gc\beta_2\in \Gamma}}}1,
\end{equation*}
where $\sum ''$ indicates that the $\b_0$ are as above  but furthermore such that there exists a vector $b^{(1)}$ in the lattice $\Lambda_\gd$ and $\beta_j=\frac{1}{W}\sum_{i=1}^4
b_i^{(j)}\nu_i$ for $j=1,2$. The argument now follows the proof of \cite[Proposition 7.5]{May15b} precisely, except that we apply Lemmas \ref{div}, \ref{WTI} for the basis $\v$ in place of \cite[Lemmas 7.3 and 7.4]{May15b}.
\end{proof}

\subsection{Initial steps in the Type II sum}

If $\a\in\cA_{q_1\cdots q_\ell}(\u_0,m,p)$ then there exists $d\in\N$ such that $N(a_1\nu_1+a_2\nu_2+a_3\nu_3)=d\prod_{i=1}^\ell q_i$.
The conditions on $q_i$ imply that $(m,q_1\cdots q_\ell )=1$ but in general, it is not clear that $(d,m)=1$.
This may gives some complications in the application of Proposition \ref{prpstn:TypeI}.
Let us write $m_0=(d,m^\infty)$ and recall the notation
$\cX=\prod_{i=1}^3 [X_i, X_i (1+\eta_1)[$ from \eqref{eq:cXDef}. In almost cases, $m_0$ is small. The contribution of the $\a\in\cX$, such that $\a\equiv\u_0\Mod m$ and $m_0>D_0$
with  $D_0=\eta_\cX^{-2}\eta_1^{-1}$ with $\eta_\cX$ defined by \eqref{defeta2} below,  is less than
\begin{equation*}\begin{split}
\sum_{\substack{ {m_0| m^\infty} \\
}} &
\sum_{\substack{ {\a\in\cX}\\
{\a\equiv\u_0\Mod m}\\
{N\big (\sum_{i=1}^3a_i\nu_i\big )\equiv 0\Mod{m_0}}
}} 1
\ll \eta_1^3\prod_{i=1}^3X_i\sum_{\substack{ {m_0| m^\infty} \\
\frac{4^{\omega (m_0)}}
&\qquad\ll \frac{\eta_1^3\prod_{i=1}^3X_i}{m^2\sqrt{D_0}}\sum_{\substack{ {m_0| m^\infty} \\
\frac{4^{\omega (m_0)}}
{\sqrt{m_0}}\ll \frac{\eta_1^3\prod_{i=1}^3X_ic^{\Omega (m)}}{m^2\sqrt{D_0}},
\end{split}
\end{equation*}
for some $c>0$ large enough.
This contribution is sufficiently small.

We now suppose that $m_0\le D_0$.

\begin{equation}\label{defMm0}\begin{split}
\cM (m_0)&=\Big\{ \v_0\in [1,mm_0]^3 : \v_0\equiv{u_0}\Mod m,\\
&\ N(\sum_{i=1}^3  (\v_0)_i\nu_i)\equiv 0\Mod {m_0},\
\big (m, \frac{N(\sum_{i=1}^3  (\v_0)_i\nu_i}{m_0}\big )=1\Big\}.\end{split}
\end{equation}
Then for every $\a\in\cA (\u_0,m)$ such that $m_0 =(N(a_1\nu_1+a_2\nu_2+a_3\nu_3),m^\infty)$,
there exists exactly one $\v_0\in\cM (m_0)$ such that $\a\equiv \v_0\Mod {mm_0}$.

We deduce that
\begin{equation}
\sum_{\substack{{\a\in\cX} \\ {\a\equiv \u_0\Mod m}\\
{(N(\sum_{i=1}^3 a_i\nu_i) ,m^\infty)\le D_0}}}1=\sum_{\substack {{m_0|m^\infty}\\ {m_0\le D_0}}}\sum_{\v_0\in\cM (m_0)}|\cA (\v_0 ,mm_0)|.
\label{eq:m0Split}
\end{equation}

Any $\a\in \cA (\v_0,mm_0)$ is such that the associated ideal $(\sum_{i=1}^3 a_i\nu_i)$ may be factored as
$(\sum_{i=1}^3 a_i\nu_i)=\gM_0 \gJ$ with $N(\gM_0)=m_0$ and $(N(\gJ),m)=1$. This property will  simplify some GCD considerations in the next sections.  Let
\begin{equation}\label{defm'}
\end{equation}
denote this extended modulus.

\subsection{Switching to ideals with norms in small boxes}

We introduce the sets of principal ideals of $\cO_K$
\begin{equation}\label{AX}
\cAI =\Big\{ \big (\sum_{i=1}^3 a_i\nu_i \big ) :  \a\in\cX\Big\}.
\end{equation}
For any $\ga\in\cAI $ there is exactly one $(a_1,a_2,a_3)\in\cX$ such that $\ga =(a_1\nu_1+a_2\nu_2+a_3\nu_3)$.
We justify this in a similar way as  in \cite[Proof of Lemma 5.2 assuming Proposition 5.1 pp. 13-14]{May15b}.

If $\alpha = \sum_{i=1}^3 a_i\nu_i$  and $\beta =\sum_{i=1}b_i\nu_i$ with $\a,\b\in\cX$ are such that $(\alpha )=(\beta)$
then $\beta\alpha^{-1}$ is a unit of $\cO_K$.
But $|\sigma ( \alpha )|\ll X$  for all embedding $\sigma$ and since $\alpha =N(\alpha)\prod_{\sigma\not = Id}\sigma (\alpha )^{-1}$ we have
$|a_1\nu_1+a_2\nu_2+a_3\nu_3|\gg \eta_1^{1/10}X$ by \eqref{eq:Xi2}
and then
\begin{equation*}
\frac{\beta}{\alpha}  =1 +\frac{\beta-\alpha}{\alpha}= 1 + O (\eta_1 ^{9/10}).
\end{equation*}
If $\alpha\not =\beta$ then $\beta\alpha^{-1}$ can't be   a unit because the length  between two  units is $\gg 1$ and we have a contradiction.

Next we consider the sets
\begin{equation*}
\cAI (\v_0 , m', p)=\Big\{ \big (\sum_{i=1}^3a_i\nu_i)\in\cAI  : \a\equiv {\v_0}\Mod {m'}\ \text{and}\  p|f(a_1,a_2,a_3)\Big\}
\end{equation*}
and for any ideal $\gd$,
\begin{equation*}
\cAI _\gd (\v_0,m', p)=\{\ga \in\cAI (\v_0 , m', p) :\gd |\ga\}.
\end{equation*}

Let $N_0^4=\min_{(\alpha )\in\cAI}N(\alpha)$.
Let $\eta_\cX$ and $\eta_2$ defined by
\begin{equation}\label{defeta2}
\eta_\cX=\frac{1}{(\log X)^A},\qquad \eta_2=\eta_\cX^{10000\ell^2}.
\end{equation}

By the definition of $\cX$, $N(a_1\nu_1+a_2\nu_2+a_3)\in [N_0^4, N_0^4(1+O(\eta_1))]$ for all
$(a_1\nu_1+a_2\nu_2+a_3)\in \cAI$. We can choose $O(\eta_2^{-1}\eta_1)$ reals $X_0$ with $X_0^4\in [N_0^4, N_0^4(1+O(\eta_1))]$ so that
the sets
\begin{equation*}\label{A'}
\cAI (X_0,\v_0 ,m',p)=\Big\{ \big (\sum_{i=1}^3 a_i\nu_i\big )\in\cAI (\v_0 ,m',p) : N\big (\sum_{i=1}^3 a_i\nu_i\big  )
\in [X_0^4, X_0^4+\eta_2X_0^4[\Big\},
\end{equation*}
form a partition of $\cAI (\v_0,m',p)$.
Next we introduce the sets
\begin{equation*}
\cAI_\gd (X_0,\v_0, m',p)=\Big\{ \big (\sum_{i=1}^3 a_i\nu_i\big )\in\cAI (X_0,\v_0 ,m',p) : \gd | \big (\sum_{i=1}^3 a_i\nu_i\big )
\Big\}.
\end{equation*}

By \eqref{eq:th4}, there exists $\varepsilon>0$ such that $X^{\sum_{i=1}^\ell \theta_i +\min (\theta_0,\ldots , \theta_\ell)}>X^{4+\varepsilon}$ and by \eqref{eq:th2} the intervals $[X^{\theta_i},X^{\theta_i'}]$ do not overlap. Thus for each $\ga \in\cAI$
such that $N(\ga )\equiv 0\Mod{q_1\cdots q_\ell}$ with
$X^{\theta_i}\le q_i\le X^{\theta_i'}$, is divisible by exactly one prime ideal $\gP_i$ with
$N(\gP_i)\in [X^{\theta_i}, X^{\theta'_i}]$ (for all $1\le i\le \ell$).

We are now ready to settle the connection between the set $\cA_q ( \v_0, m',p)$ in Theorem \ref{DistriNorm} and the  sets of ideals just defined above. For any primes $q_1,\ldots ,q_\ell$ with $q_i\in [X^{\theta_i}, X^{\theta_i'}]$, we have
\begin{equation}\label{corresp}
|\cA_{q_1\cdots q_\ell} ( \v _0, m',p)|=\sum_{X_0}\sum_{N(\gP_i)=q_i}|\cAI _{\gP_1\cdots \gP_\ell}(X_0,\v_0,m',p)|.
\end{equation}

Any ideal  $(a_1\nu_1+a_2\nu_2+a_3\nu_3)$ counted in \eqref{corresp} may be factored as

\begin{equation}\label{facto}
(a_1\nu_1+a_2\nu_2+a_3\nu_3)=\gM_0\gI\prod_{i=1}^\ell \gP_i,
\end{equation}
where each $\gP_i$ is a prime ideal with norm in $[X^{\theta_i}, X^{\theta'_i}]$ and $\gI$ is an ideal with
\begin{equation}\label{lesI}
N(\gI)\in  \cI_0:=\Bigl[\frac{X_0^4X^{-\sum_{i=1}^\ell \theta_i'}}{m_0},\frac{ X_0^4(1+\eta_2)X^{-\sum_{i=1}^\ell\theta_i}}{m_0}\Bigr]=[I_1,I_2],
\end{equation}

We  choose now  $O(\eta_2^{-1}\log X)$  reals $I\in \cI_0$ such that $\cI_0$ is covered by
the union of the intervals $[I, I(1+\eta_2)[$. Let $\hat \cI_0$ denote the set of these reals $I$.

Since we have $(N(\sum_{i=1}^3a_i\nu_i)/m_0 ,m)=1$ when $\a\equiv\v_0\Mod{m'}$, we have
$(m',N(\gI)\prod_{i=1}^\ell N(\gP_i))=1$.

For brevity we will write  $\cAI (\v_0,m',p)$ in place of $\cAI (X_0,  \v_0,m',p)$ when the context will be clear.

To have  a precise control of the size of the norms of some ideals,
we  cover  each interval $[\theta_i, \theta'_{i}]$    by $O(\eta_\cX^{-2})$ distinct intervals  of size $O(\eta_\cX^2)$
so that,
\begin{equation}\label{UnionRl}
\prod_{i=1}^\ell [\theta_i,\theta'_i]=\cup_{\bl \in E}\cR (\bl),
\end{equation}
where $E$ is some subset of $\N^\ell$ and each $\cR (\bl)$ is of type $\cR (\bl)=\prod_{i=1}^\ell [t_i,t'_i )$
with $|t_i'-t_i|\ll \eta_\cX^2$  (except that in  the  intervals with $t'_i=\theta_i'$  we take the whole   segment $[t_i,\theta_i' ]$),   (cf \cite[section 8 p.45]{May15b}).

We write $\cR (\bl)=\prod \cR_1 (\bl)\times \cR_2 (\bl)$ with $\cR_2(\bl)$ representing the first $\ell '$ coordinates and $\cR_1 (\bl)$ the final  $\ell -\ell'$ coordinates.

For a polytope $\cR\subset\R^s$ (for some $s$), we define
\begin{equation*}
\1_\cR (\ga )=\begin{cases}
1, & \ga =\gp _1\cdots \gp _s\ {\rm with}\ N(\gp _i)=X^{e_i}\ {\rm and }\ (e_1,\ldots ,e_s )\in\cR,\\
0, & {\rm otherwise.}
\end{cases}
\end{equation*}
Thus we need to study the quantity
\begin{equation}
T(\cR(\bl )):=\sum_{X^\tau\le p\le X^{\tau'}}\sum_{\gI\in\cI }\sum_{\gM_0\gI\ga\in \cA (\v_0,m',p)}\1_{\cR (\bl)}(\ga),
\label{eq:TRDef}
\end{equation}
with $\cI :=\{ \gI : N(\gI)\in [I,I+\eta_2I[, (N(\gI),m)=1\}$.

\subsection{Approximation weights}

We recall that $\eta_2=\eta_\cX^{10000\ell ^2}$.
A key idea of [14] is to approximate the indicator $\1_{\cR_2}$ by a weight $\tilde \1_{\cR_2}$
which will be more easy to control.
For $\cS\subset \R^s$ we consider the function
\begin{equation}
c_\cS (t)=\iint_{\substack{{(e_1,\ldots ,e_s)\in\cS}\\ {\sum_{i=1}^s e_i\in I_t}}}
\frac{de_1\cdots de_{s }}{\eta_2^{1/2}\prod_{i=1}^s e_i},\label{eq:CDef}
\end{equation}
\begin{equation*}
{\rm where}\ I_t :=\Big [\frac{\log t}{\log X},\frac{\log (t+\eta_2^{1/2}t)}{\log X}\Big ].
\end{equation*}
In this previous definition we have $\sum_{i=1}^\ell e_i\in I_t$ if and only if $X^{\sum_{i=1}^\ell e_i}\in [t,t (1+\sqrt{\eta_2}]$.
This function is so that $c_\cS (N(\ga))$ corresponds to the probability for an ideal of norm close to $N(\ga)$ to
have a prime factorisation compatible  with $\cS$  (cf. \cite[section 8]{May15b}).
We recall below some properties of this function that we will frequently use later on.
\begin{lmm}\label{cR}
\begin{itemize}
\item If $\cS=\prod_{i=1}^s [s_i,s'_i]$ is an hyperrectangle with $\min s_i >\varepsilon_0 >0$ and $\ell >1$, then
\begin{equation*}
c_\cS (t+\delta)-c_\cS (t)\ll\frac{\delta}{t}
\end{equation*}
\item If $\cS=\prod_{i=1}^s [s_i,s'_i]$ is an hyperrectangle  with $\min s_i >\varepsilon_0 >0$    then
\begin{equation*}
c_\cS (t)\ll_{\varepsilon_0} \frac{1}{\log X}.
\end{equation*}
\end{itemize}
\end{lmm}
\begin{proof}
The first part is a particular case of \cite[Lemma 8.3  (iii)]{May15b}.
The proof of the second point is a direct computation analogous to [14] :
\begin{equation*}
c_\cS (t)\le\frac{1}{\sqrt{\eta_2}}\iint_{\substack{{e_i\in [s_i , s_i']}\\ {1\le i\le s -1}}}\Big [\int_{e_s\in I_t-\sum_{i=1}^{s-1}e_i}\frac{\d e_s}{s_s}\Big ]\prod_{i=1}^{s -1}\frac{\d e_i}{s_i}.
\end{equation*}
The integral over $e_\ell$ is $O(\sqrt{\eta_2}(\log X)^{-1})$ and the contribution of the other integrals is $O(1)$.
\end{proof}

Let $\varepsilon_{00}>0$ and $R:=X^{\varepsilon_{00}}$. The approximate weights of $\1_{\cR_2}$ are defined by
\begin{equation}
\tilde \1_{\cR_2}(\gb):=c_{\cR_2}(N(\gb ))\sum_{\gd |\gb}\lambda_\gd,\label{eq:TildeDef}
\end{equation}
\begin{equation*}
\lambda _\delta := \begin{cases}
\mu (\gd )\log \frac{R}{N(\gd )}, & N(\gd)<R,\\
0, & {\rm otherwise.}
\end{cases}
\end{equation*}
\begin{rmk}
Our weights are somewhat simpler than the one introduced in [14], because we don't need to take care of the perturbations caused by a possible exceptional character $\chi ^*$. (Ultimately we will only require estimates with moduli up to a fixed power of $\log{X}$, whereas in [14] larger moduli needed to be considered due to losses occurring in high dimensions.)
\end{rmk}
We now write
\[
T(\cR)=T_{sieve}(\cR )
+T_1(\cR ),
\]
\begin{align}
T_{sieve}(\cR)&:=\sum_{\substack{{p\in [P_1,P_2]}\\ {p\equiv 1\Mod {D_f}}}}\sum_{\gI\in\cI}\sum_{\gM_0\gI\ga\gb\in\cAI(\v_0,m',p)}\1_{\cR_1}(\ga)\tilde\1_{\cR_2}(\gb),\label{eq:TSieveDef}\\
T_1(\cR)&:=\sum_{\substack{{p\in [P_1,P_2]}\\ {p\equiv 1\Mod{D_f}}}}\sum_{\gI\in\cI}\sum_{\gM_0\gI\ga\gb\in\cAI (\v_0 ,m',p)}\1_{\cR_1}(\ga)(\1_{\cR_2}(\gb)-\tilde\1_{\cR_2}(\gb)),\label{TsT1}
\end{align}
\[
P_1:=X^{\tau}, \qquad
\]

For brevity again we will write $T_{sieve}(\cR)$ and $T_1 (\cR)$ in place of $T_{sieve}(\cR , \v_0)$ and $T_1 (\cR ,\v_0)$ when $\v_0$ is clear from the context. We see that Theorem \ref{DistriNorm} follows immediately from the following two propositions.
\begin{prpstn}[Estimate for $T_{sieve}$]\label{prpstn:TSieve}
If we have
\[\epsilon_{00}<\sum_{j=1}^{\ell'}\theta_j-1-12\tau',\]
\begin{align*}
T_{sieve}(\cR)=(2+O(\eta_2^{1/2}))\log({1+\eta_2})|\cAI(X_0)| c_{\cR_1\times \cR_2}(X_0^4/mI)\frac{g(m')}{m'{}^3}\frac{\log(P_2/P_1)}{\varphi(D_f)},
\end{align*}
\begin{align*}
g(m')=\prod_{\gP| (m')}\Big ( 1-\frac{\varrho_\v (\gP)}{N(\gP)}\Big )^{-1}.
\end{align*}
\end{prpstn}
\begin{prpstn}[Bound for $T_1(\cR)$]\label{prpstn:T1}
Let $\cR=\cR_1\times\cR_2$ and $T_1(\cR)$ be as above. If we have
\[
\tau'<\min\Bigl(\frac{4-2\theta'_{1}-\ldots-2\theta'_{\ell '}}{100},\frac{\theta_1+\cdots+\theta_{\ell'}-1}{100}\Bigr),
\]
then for any $A>0$ we have
\[
T_1(\cR)\ll_A \frac{|\cAI(X_0)|}{(\log{X})^A}.
\]
\end{prpstn}
We remark that we are assumming the general setup in Propositions \ref{prpstn:TSieve} and \ref{prpstn:T1}; in particular, the constants $\theta_1,\theta_1',\dots,\theta_\ell,\theta_{\ell}'$ determining $\cR$ are assumed to satisfy \eqref{eq:th1}-\eqref{eq:th5}.

We will establish Proposition \ref{prpstn:TSieve} in Section \ref{sec:TSieve} and the harder Proposition \ref{prpstn:T1} in Section \ref{sec:T1}. The presence of the sum over primes $p\in [P_1,P_2]$ introduces few additional complications to $T_{sieve}$ and Proposition \ref{prpstn:TSieve}, but quite significant additional technical details to $T_1$ and Proposition \ref{prpstn:T1}. Assuming these propositions for now, we can establish Theorem \ref{DistriNorm} by putting all our manipulations together.

\begin{proof}[Proof of Theorem \ref{DistriNorm} assuming Propositions \ref{prpstn:TSieve} and \ref{prpstn:T1}]
We recall from \eqref{eq:m0Split} and \eqref{AX}
\begin{equation}
\cA_{q_1\cdots q_\ell}(\u_0,m,p)=\sum_{\substack{m_0|m^\infty \\ m_0\le D_0}}\sum_{\v_0\in\cM(m_0)}|\cAI_{q_1\cdots q_\ell}(\v_0,m',p)|+O\Bigl(\frac{\eta_1^3\prod_{i=1}^3 X_i}{m^2 D_0^{1/2}}\Bigr).
\label{eq:AAt}
\end{equation}
We concetrate on the $\cAI$ terms. We recall from \eqref{corresp}, \eqref{lesI} and \eqref{eq:TRDef} that
\begin{align*}
&|\cAI_{q_1\cdots q_\ell} ( \v _0, m',p)|=\sum_{X_0}\sum_{N(\gP_i)=q_i}|\cAI _{\gP_1\cdots \gP_\ell}(X_0,\v_0,m',p)|\\
&=\sum_{X_0}\sum_{\substack{\cI \\ \sqcup \cI=\cI_0}}\sum_{N(\gP_i)=q_i}\sum_{\substack{\gJ\\ N(\gJ)\in\cI \\ \gM_0\gJ\prod_{i=1}^\ell\gP_i\in \tilde{A}(\v_0,m',p)}}1\\
&=\sum_{X_0}\sum_{\substack{\cI \\ \sqcup \cI=\cI_0}}\sum_{\substack{\cR_1,\cR_2 \\ \prod_{i=1}^\ell [\theta_i,\theta_i']=\sqcup \cR_1\times\cR_2}}\sum_{\substack{\gJ\\ N(\gJ)\in\cI}}\sum_{\ga}\1_{\cR_1}(\ga)\sum_{\substack{\gb \\ \gJ\gM_0\ga\gb\in \tilde{A}(\v_0,m',p)}}\mathbf{1}_{\cR_2}(\gb).
\end{align*}

By assumption of Theorem \ref{DistriNorm}, we have $\tau'<(\sum_{i=1}^{\ell'}\theta_i-1)/100$, and so choosing $\epsilon_{00}$ sufficiently small means that the hypothesis of Proposition \ref{prpstn:TSieve} is satisfied. Thus, summing over $p\in [P_1,P_2]$ and applying Propositions \ref{prpstn:TSieve} and \ref{prpstn:T1} (with a suitably large constant $A$) gives
\begin{align}
&\sum_{p\in[P_1,P_2]}|\cAI_{q_1\cdots q_\ell} ( \v _0, m',p)|=\sum_{X_0}\sum_{\substack{\cI \\ \sqcup \cI=\cI_0}}\sum_{\substack{\cR=\cR_1\times\cR_2 \\ \prod_{i=1}^\ell [\theta_i,\theta_i']=\sqcup \cR_1\times\cR_2}}\Bigl(T_{sieve}(\cR)+T_1(\cR)\Bigr)\nonumber\\
\end{align}
\[
T_3:=\sum_{X_0}\sum_{\substack{\cI \\ \sqcup \cI=\cI_0}}\sum_{\substack{\cR=\cR_1\times\cR_2 \\ \prod_{i=1}^\ell [\theta_i,\theta_i']=\sqcup \cR_1\times\cR_2}}|\cAI(X_0)|c_{\cR}(X_0^4/mI).
\]
Here we used that there are at most $O(\eta_\cX^{-2})$ subsets $\cR $, $O(\eta_2^{-1}\eta_1)$ reals $X_0$ and  $O(\eta_2^{-1}\log X)$ reals $I$ to bound the contribution from $T_1$ by  Proposition \ref{prpstn:T1}.

We now concentrate on $T_3$. Since the subsets  $\cR$ form a partition of $\cT:=\prod_{i=1}^\ell [\theta_i,\theta_i']$, we find
$$\sum_{\substack{\cR=\cR_1\times\cR_2 \\ \prod_{i=1}^\ell [\theta_i,\theta_i']=\sqcup \cR_1\times\cR_2}}c_{\cR}(X_0^4/mI)=c_\cT (X_0^4/mI),$$
\[
T_3=\sum_{X_0}|\cAI(X_0)|\sum_{\substack{\cI \\ \sqcup \cI=\cI_0}}c_\cT (X_0^4/mI).
\]
By Lemma \ref{cR} applied to $c_\cT$ we have for all  $I\in\cI_0$
\begin{equation*}\begin{split}
c_\cT (X_0^4/mI)&=\frac{1}{\eta_2}\int_{I}^{I(1+\eta_2)}\frac{c_\cT (X_0^4/mv)}{v}dv+O(\eta_2).\\
\end{split}
\end{equation*}
Expanding the definition \eqref{eq:CDef} of $c_{\cT}$ and swapping the order of summation and integration, we find
\begin{align*}
\sum_{I\in\hat\cI_0}\int_{I}^{I(1+\eta_2)}&\frac{c_\cT (X_0^4/mv)}{v}dv\\
\iint\limits_{\substack{{e_i\in [\theta_i,\theta_i']}\\ {1\le i\le\ell}}}
\sum_{I\in\hat\cI_0}\int\limits_{\substack{v\in [I,I(1+\eta_2)[\\ v\in \Big [\frac{X_0^4}{m\prod_{i=1}^\ell X^{e_i}}, \frac{X_0^4(1+\sqrt{\eta_2})}{m\prod_{i=1}^\ell X^{e_i}}\Big ]}}
\frac{dv}{v}\prod_{i=1}^\ell \frac{\d e_i}{e_i}\\
&=\frac{1}{\eta_2^{1/2}}\iint\limits_{\substack{ e_i\in [\theta_i,\theta_i'] \\ 1\le i\le\ell }}\Bigl(\int_{X_0^4/(m\prod_{i=1}^\ell X^{e_i})}^{X_0^4(1+\sqrt{\eta_2})/(m\prod_{i=1}^\ell X^{e_i})}\frac{dv}{v}\Bigr)\prod_{i=1}^\ell \frac{\d e_i}{e_i}\\
&=\frac{\log(1+\sqrt{\eta_2})}{\eta_2^{1/2}}\prod_{i=1}^\ell \log\Big (\frac{\theta_i'}{\theta_i}\Big ).
\end{align*}
We note that this is independent of $X_0$, so we find
\begin{align}
T_3&=\frac{\log(1+\sqrt{\eta_2})}{\eta_2^{3/2}}\prod_{i=1}^\ell \log\Big (\frac{\theta_i'}{\theta_i}\Big )\sum_{X_0}|\cAI (X_0)|+O\Bigl(\log{X}\sum_{X_0}|\cAI (X_0)|\Bigr)\nonumber\\
&=\frac{(1+O(\sqrt{\eta_2}))}{\eta_2}\prod_{i=1}^\ell \log\Big (\frac{\theta_i'}{\theta_i}\Big )|\cAI (X)|.\label{eq:T33}
\end{align}
Putting together \eqref{eq:AAt}, \eqref{eq:AtT3} and \eqref{eq:T33} we find
\begin{align}
\sum_{p\in[P_1,P_2]}&\sum_{\substack{q_1,\dots q_\ell \\ q_i\in [X^{\theta_i},X^{\theta_i'}]}}\cA_{q_1\cdots q_\ell}(\u_0,m,p)\nonumber\\
&=2\frac{\log{\frac{P_2}{P_1}}}{\phi(D_f)}\prod_{i=1}^\ell \log\Big (\frac{\theta_i'}{\theta_i}\Big )|\cAI (X)|\sum_{\substack{m_0|m^\infty \\ m_0\le D_0}}\sum_{\v_0\in\cM(m_0)}\frac{g(m')}{m'{}^3}\nonumber\\
&\qquad+O\Bigl(\eta_2^{1/2}\prod_{i=1}^3 X_i\Bigr)+O\Bigl(\frac{\eta_1^3\prod_{i=1}^3 X_i}{D_0^{1/2}}\Bigr).
\label{eq:MainEst}
\end{align}
Finally it remains to estimate the inner double sum. The summand is independent of $\v_0$, so recalling that $m'=m_0m$ we are left to estimate
\begin{equation}\label{Sm0}
\sum_{\substack{{m_0<D_0}\\
{m_0|m^\infty}}}\frac{|\cM (m_0)|}{(mm_0)^3}\prod_{\gP| (m)}\Big (\sum_{k=2}^\infty \frac{\varrho_\v(\gP^k)}{N(\gP^k)}\Big )^{-1}.
\end{equation}
By \eqref{defMm0},
$$|\cM(m_0)|\le m_0^2m,$$ and thus for any given $m$
the sum over $m_0$ converges. We may therefore extend it to all $m_0\ge 1$ cost of an admissible error term.
Next we note that the sets of the $\a\in [1,X]^3$
with $\a\equiv \u_0\Mod m$ can be partitioned into sets of the $\a\in [1,X]^3$ such that $\a\equiv{\v_0}\Mod {mm_0}$, with $m_0\le X^2$ and $\v_0\in\cM (\u_0)$, and so
\begin{equation*}
\begin{split}
\sum_{\substack{{m_0<D_0}\\
{m_0|m^\infty}}}\frac{|\cM (m_0)|}{(mm_0)^3}&=
{m_0|m^\infty}}}\frac{|\cM (m_0)|}{(mm_0)^3}\\
&= \frac{(1+O(D_0^{-1/4})}{X^3+O(X^2)}
\sum_{\substack{{m_0<X^2}\\
{m_0|m^\infty}}}\sum_{\v_0\in\cM (m_0)}
\sum_{\substack{{\a\in [1,X]^3}\\ {\a\equiv{\v_0}\Mod{m_0}}}}1\\
\sum_{\substack{{\a\in [1,X]^3}\\ {\a\equiv{\u_0}\Mod{m_0}}}}1\\
\end{split}
\end{equation*}
Substituting this into \eqref{eq:MainEst} and recalling $D_0=\eta_\cX^{-2}\eta_1^{-1}\gg (\log{X})^{2A}$, $\eta_2\ll (\log{X})^{-2A}$ and $|\cAI(X)|=\eta_1^3X_1X_2X_3+O(\eta_2X_1X_2X_3)$ gives Theorem \ref{DistriNorm}.
\end{proof}
\section{Proposition \ref{prpstn:TSieve}: The term $T_{sieve}(\cR)$.}\label{sec:TSieve}
In this part we obtain an analogue of \cite[Lemma 8.6]{May15b} by expanding the sieve terms and applying Proposition \ref{prpstn:TypeI}.

If $\ga$  and $\gb$ are  some ideals satisfying $\1_{\cR_1} (\ga )=\1_{\cR_2}(\gb)=1$ then $\ga$ and $\gb$
factor into prime ideals as $\ga =\prod_{i=\ell'+1}^\ell \gP_i$, $\gb=\prod_{i=1}^{\ell '} \gP_i$
with $N(\gP_i)\in [X^{t_i},X^{t_i}(1+O(\eta_\cX^2\log X))]$ for $1\le i\le\ell$.
In particular,
\[
N(\ga)\in [A^4, A^4(1+O(\eta_\cX^2\log X))],\quad N(\gb)\in  [B^4, B^4(1+O(\eta_\cX^2\log X))]
\]
\[
A^4:=X^{\sum_{i=\ell'+1}^\ell t_i},\quad  B^4:=X^{\sum_{i=1}^{\ell '}t_i}.
\]
\begin{lmm}\label{lmm:TSplit}
Let $B^4>X^{1+\epsilon}R$ and $\cR=\cR_1\times \cR_2$. Then we have
\[
\]
where $M_1(\cR)$ is given by
\begin{align*}
M_1(\cR)&:=\sum_{\substack{ {p\in [P_1,P_2]}\\ {p\equiv 1\Mod{D_f}}}}
\sum_{\gI\in\cI}\sum_{\ga}\1_{\cR_1}(\ga )\sum_{\substack{{N(\gd )<R}\\ {N(\gd),m)=1}}}\lambda_\gd\nonumber\\
&\qquad\times c_{\cR_2}\Big (\frac{X_0^4}{m_0N(\a \gI)}\Big )|\cAI_{\ga\gd\gI}(\v_0(\y),m',p)|,
\end{align*}
and $E_1(\cR)$ satisfies
\[
\sum_{\cR}\sum_{X_0}|E_1(\cR)|\ll \eta_2^{1/2}\eta_1^{-2\ell}(\log X)^{11}\prod_{i=1}^3X_i.
\]
\end{lmm}
\begin{proof}
We substitute our definition \eqref{eq:TildeDef} of $\tilde \1_{\cR_2}$ into our expression \eqref{eq:TSieveDef} for $T_{sieve}$, and write $\gu=\gM_0\gI\ga\gb$. This gives
\begin{equation}\label{MR}\begin{split}
T_{sieve}(\cR)&=\sum_{\substack{{p\in[P_1,P_2]}\\ {p\equiv 1\Mod{D_f}}}}\sum_{\gI\in\cI}\sum_{\ga}\1_{\cR_1}(\ga )\sum_{N(\gd )<R}\lambda_\gd
\sum_{\substack{{\gu\in\cAI(\v_0,m',p)}\\ {\gM_0\gI\ga\gd |\gu}\\ }}
c_{\cR_2}(N(\gu /\a \gI\gM_0)).\end{split}
\end{equation}
If $\gu\in \cAI (\v_0,m',p)$ then $N(\gu )\in [X_0^4,X_0^4(1+\eta_2)]$. By  Lemma \ref{cR}, this implies
$c_{\cR_2}(N(\gu /\a \gI\gM_0))=c_{\cR_2}(X_0^4/m_0N(\a \gI))+O(\eta_2).$ Thus we write
\begin{equation}
\end{equation}
where $M_1(\cR)$ is as given in the Lemma and
\begin{align}
E_1(\cR)&:= \eta_2
\sum_{\substack{{p\in[P_1,P_2]}\\ {p\equiv 1\Mod{D_f}}}}\sum_{\gI\in\cI}\sum_{\ga}\1_{\cR_1}(\ga)\sum_{N(\gd )<R}|\lambda _\gd||\cAI _{\gI\ga\gd}(\v_0,m',p)|.\label{cc}
\end{align}
We concentrate on $E_1(\cR)$. For any $(\sum_{i=1}^3x_i\nu_i)\in\cAI $, the number of primes $p\in [P_1,P_2]$ such that $p| f(x_1,x_2,x_3)$ is finite. This allows us to remove the summation over $p$ and replace $|\cAI _{\gI\ga\gd}(\v_0,m',p)|$ with $|\cAI _{\gI\ga\gd}(\v_0,m',1)|$ in $E_1(\cR)$ at the cost of a factor $O(1)$.

We then apply Proposition \ref{prpstn:TypeI} to estimate $|\cAI _{\gI\ga\gd\gM_0}(\v_0,m',1)|$, recalling that $N(\gI\ga\gd\gM_0)\ll X^4 R/B^4$ and $m'\ll (\log X)^{O(1)}$. This gives
\begin{equation}\label{resteT1}\begin{split}
E_1(\cR)&\ll \eta_2
\sum_{\gI\in\cI}\sum_{\ga}\1_{\cR_1}(\ga)\sum_{\substack{{N(\gd )<R} \\ {(N(\gd ),m')=1}}}|\lambda _\gd|\frac{|\cAI (X_0,\cX) |\varrho_\v (\ga\gd\gI ) }{N(\ga\gI\gd)(m')^3}\\
&+X^{o(1)}\sum_{\substack{{N(\gd )<R}\\ {(N(\gd ),m)=1}}}|\lambda _\gd|\Bigl(X^{2}\Bigl(\frac{X^4 R}{B^4} \Bigr)^{1/3}+\frac{X^4 R}{B^4}X\Bigr).
\end{split}
\end{equation}
Crudely, if $B^4>X^{1+\epsilon}R$, we see the second term in \eqref{resteT1} contributes to \eqref{resteT1}
\begin{equation}\label{E12}
\ll X^{3+o(1)}\Bigl(\frac{X R^4}{B^4}+\Bigl(\frac{X R^4}{B^4}\Bigr)^{1/3}\Bigr)\ll X^{3-\epsilon/4}.
\end{equation}
By an Euler product upper bound and Lemma \ref{rhodrhoI}, we see that the first term contributes to \eqref{resteT1}
\begin{align}
&\ll \eta_2(\log{X}) |\cAI(X_0,\v_0,m')|\sum_{N(\gI),N(\ga),N(\gd)<X}\frac{|\rho_\v(\ga\gd\gI)|}{N(\ga\gd\gI)}\nonumber\\
&\ll\eta_2(\log{X})^{9} |\cAI(X_0,\v_0,m')|.\label{E11}
\end{align}
Thus, substituting \eqref{E12} and \eqref{E11} into \eqref{resteT1} we find for $B^4>X^{1+\epsilon}R$
\[
E_1(\cR)\ll \eta_2(\log{X})^{9} |\cAI(X_0,\v_0,m')|+X^{3-\epsilon/4}.
\]
Summing this over all hyperrectangles $\cR$ and all relevant $X_0$, we find
\begin{align}
\sum_{\cR}\sum_{X_0}E_1(\cR)&\ll \eta_2(\log{X})^{9}\sum_{\cR}\sum_{X_0} |\cAI(X_0,\v_0,m')|+X^{3-\epsilon/5}.\nonumber\\
&\ll \eta_2\eta_\cX^{-2\ell}(\log{X})^4|\cAI (\v_0,m')|+X^{3-\epsilon/5}\nonumber\\
&\ll \eta_2^{1/2}\eta_1^{-2\ell}(\log X)^{11}\prod_{i=1}^3X_i+X^{3-\epsilon/5}.
\end{align}
This gives the result.
\end{proof}

Thus we have to evaluate $M_1(\cR)$.
\begin{lmm}\label{lmm:M1}
Let $B^4>X^{1+\epsilon}RP_2^{12}$ and let $M_1(\cR)$ be as given by Lemma \ref{lmm:TSplit}. Then we have
\[
M_1(\cR)=(2+O(\eta_2^{1/2}))(\log{1+\eta_2})|\cAI(X_0)| c_{\cR_1\times \cR_2}(X_0^4/mI)\frac{g(m')}{m'{}^3}\frac{\log(P_2/P_1)}{\varphi(D_f)}.
\]
\end{lmm}
\begin{proof}
First we want to apply Proposition \ref{prpstn:TypeI} to estimate $|\cAI_{\ga\gd\gJ}(\v_0,m',p)|$. To do this we split according to residue classes $\Mod{p}$. For any $(y_1,y_2,y_3)$ such that $f(y_1,y_2,y_3)\equiv 0\Mod p$ let $\ut_0 (\y)$ be a solution of the two equations $\ut_0(\y)\equiv \y\Mod p$ and $\ut_0 (\y)\equiv \v_0\Mod {m'}$. Thus
\[
|\cAI_{\ga\gd\gI}(\v_0,m',p)|=\sum_{\substack{y_1,y_2,y_3\Mod{p}\\ f(y_1,y_2,y_3)\equiv 0\Mod{p}}}|\cAI_{\ga\gd\gI}(\ut_0(\y),p m',1)|
\]
We recall that $p\le P_2$ and $N(\gI\ga\d)\ll X R/B$. Therefore, by Proposition \ref{prpstn:TypeI}, we can replace $|\cAI_{\ga\gd\gI}(\ut_0(\y),p m',1)|$ with $\rho_{\v}(\ga\gd\gI)|\cA(X_0,\chi)|/p^3m'{}^3N(\ga\gd\gI)$ in $M_1(\cR)$ at the cost of a term bounded by
\[
\sum_{p\le P_2}\sum_{\substack{y_1,y_2,y_3\Mod{p}\\ f(y_1,y_2,y_3)\equiv 0\Mod{p}}}\Bigl(X^{2+o(1)}\Bigl(\frac{X R}{B^4}\Bigr)^{1/3}P_2+X^{o(1)} \frac{X R}{B^4}P_2^4\Bigr).
\]
This is $O(X^{3-\epsilon/4})$ provided $B^4>X^{1+\epsilon}RP_2^{12}$.

Since the function $\varrho_\v$ is multiplicative, $(\ga, \gd\gI)=1$,  and $\ga$ is a product of degree one prime ideals of large enough norm, by Lemma \ref{rhov}, we have
$\varrho _\v (\ga\gd\gI)/N(\ga\gd\gI)=\varrho_\v (\gd\gI)/(N(\gd\gI)N(\ga))$. Thus
\begin{equation}
\label{eq:M1}
\end{equation}
\begin{align}
M_2(\cR)&:=  |\cAI(X_0,\cX)|\Bigl(\sum_{\substack{ {p\in [P_1,P_2]}\\ {p\equiv 1\Mod{D_f}}}}\frac{n_p}{p}  \Bigr)\Bigl(\sum_{\gI\in\cI}Z_1(\gI)Z_2(\gI)\Bigr),\label{eq:M2}\\
Z_1(\gI)&:=\sum_\ga \1_{\cR_1}(\ga)\frac{c_{\cR_2}(X_0^4/(m_0N(\a \gI)))}{N(\ga)},\\
Z_2(\gI)&:=\sum_{\substack{{N(\gd )<R}\\ {(N(\gd),m')=1}}}
\lambda_\gd
\frac{\varrho_\v (\gd\gI)}{N(\gd\gI)(m')^3}\\
n_p&:=\frac{1}{p^2}|\{y_1,y_2,y_3\Mod{p}:\,f(y_1,y_2,y_3)\equiv 0\Mod{p}\}|.\label{eq:NpDef}
\end{align}
First we simplify $Z_1(\gI)$. Since this is a sum of a smooth function over products of $\ell$ prime ideals in a bounded region, this can be estimated using the Prime Ideal Theorem. Following the arguments of \cite[Section 8, proof of Lemma 8.6]{May15b} we find that
\begin{equation*}
Z_1(\gI) =c_{\cR_1\times \cR_2} (X_0^4/m_0N(\gI))+O(\eta_2).
\end{equation*}
We recall that $\cI=\{\gI:(N(\gI),m)=1,\,N(\gI)\in [I,I+\eta_2 I]\}$.

Thus, by Lemma \ref{cR}, we have
\begin{equation}
Z_1(\gI) =c_{\cR_1\times \cR_2} (X_0^4/m_0 I)+O(\eta_2).
\label{eq:Z1}
\end{equation}
Now we consider $Z_2(\gI)$. By Lemma \ref{Perron} we find that
\begin{equation}
Z_2(\gI)=\frac{h (\gI)g((m'))\Sft}{\gamma_K m'{}^3} +O(16^{\omega ((m)\gI)}\exp (-c\sqrt{\log R})) ,
\label{eq:Z2}
\end{equation}
\begin{align*}
g((m))&:=\prod_{\gP |(m)}\Big ( 1-\frac{\varrho_\v (\gP)}{N(\gP)}\Big )^{-1}, \\
\end{align*}
Putting together \eqref{eq:Z1} and \eqref{eq:Z2}, we see that
\begin{equation}
\sum_{\gI\in\cI}Z_1(\gI)Z_2(\gI)=\frac{g((m'))\Sft c_{\cR_1\times \cR_2}(X_0^4/m_0I)}{\gamma_K m'{}^3}\sum_{\gJ\in\cI}h(\gJ)+O(\eta_2^2 I).
\label{eq:Z1Z2Sum}
\end{equation}
Since $h(\gI)$ is multiplicative, the sum can be calculated by a contour computation
\begin{align}
\sum_{\gJ\in\cI}h(\gJ)&=\frac{1}{2\pi i}\int_{2-i\infty}^{2+i\infty} \frac{I^s ((1+\eta_2)^s-1)}{s}\sum_{\gI} \frac{h(\gI)}{N(\gI)^s}ds\nonumber\\
&=\text{Res}_{s=0}\Bigl(\frac{I^s ((1+\eta_2)^s-1)}{s}\sum_{\gI} \frac{h(\gI)}{N(\gI)^s}\Bigr)+O(\exp(-c\sqrt{\log{R}})).\label{eq:hContour}
\end{align}
We see that the residue is given by
\begin{align}
&=\gamma_K\log(1+\eta_2)\prod_{\gP}\Biggl(1+\Bigl(1-\frac{\rho(\gP)}{N(\gP)}\Bigr)^{-1}\Bigl(\sum_{e\ge 1}\Bigl(\frac{\rho(\gP^e)}{N(\gP^e)}-\frac{\rho(\gP^{e+1})}{N(\gP^{e+1})}\Bigr)\Bigr)\Biggr)\Bigl(1-\frac{1}{N(\gP)}\Bigr)\nonumber\\
\end{align}
Putting together \eqref{eq:Z1Z2Sum} \eqref{eq:hContour} and \eqref{eq:hResidue} we see that
\begin{equation}
\sum_{\gI\in\cI}Z_1(\gI)Z_2(\gI)=\frac{g((m'))(\log{1+\eta_2})c_{\cR_1\times \cR_2}(X_0^4/m_0I)}{m'{}^3}+O(\eta_2^2 I).
\label{eq:Z1Z2Sum2}
\end{equation}
Finally, we recall the definition \eqref{eq:NpDef} of $n_p$. Since $f$ is the product of two linear factors when $p\equiv 1\Mod{D_f}$, we have $n_p=2+O(1/p)$ for all $p\in[P_1,P_2]$. Thus
\begin{equation}
\sum_{\substack{p\in [P_1,P_2]\\p\equiv 1\Mod{D_f}}}\frac{n_p}{p}=\frac{(2+O(\eta_2))\log(P_2/P_1)}{D_f}.
\label{eq:fBound}
\end{equation}
Putting together \eqref{eq:M1}, \eqref{eq:M2}, \eqref{eq:Z1Z2Sum2} and \eqref{eq:fBound} now gives the result.
\end{proof}
We are now in a position to establish Proposition \ref{prpstn:TSieve}.
\begin{proof}[Proof of Proposition \ref{prpstn:TSieve}]
We see that putting together Lemma \ref{lmm:TSplit} and \ref{lmm:M1} gives
\[
T_{sieve}=(2+O(\eta_2^{1/3}))\eta_2|\cAI(X_0)| c_{\cR_1\times \cR_2}(X_0^4/mI)\frac{g(m')}{m'{}^3}\frac{\log(P_2/P_1)}{\varphi(D_f)}.
\]
provided $B^4>X^{1+\epsilon}RP_2^{12}$. Recalling that $R=X^{\epsilon_{00}}$, $P_2=X^{\tau'}$, $B^4=X^{\sum_{i=1}^{\ell'}t_i}\ge X^{\sum_{i=1}^{\ell'}\theta_i}$ we see that this condition is satisfied provided
\[
\sum_{i=1}^{\ell'}\theta_i>1+\epsilon_{00}+12\tau'
\]
and $\epsilon$ is taken sufficently small. This gives the result.
\end{proof}

\section{Proposition \ref{prpstn:T1}: The term $T_1(\cR)$}\label{sec:T1}

In this section we use the dispersion method to bound $T_1(\cR)$ and establish Proposition \ref{prpstn:T1}. Let us recall the expression of $T_1(\cR)$
\begin{equation*}
T_1(\cR)=\sum_{\substack{{p\in [P_1,P_2]}\\ {p\equiv 1\Mod {D_f}}}}\sum_{\gI\in\cI}\sum_{\gM_0\gI\ga\gb\in\cAI(\v_0,m',p)}\1_{\cR_1}(\ga)(\1_{\cR_2}(\gb)-\tilde\1_{\cR_2}(\gb)).
\end{equation*}
To simplify some notation we will write
\begin{equation}
\tilde g(\gb ):=\1_{\cR_2}(\gb)-\tilde\1_{\cR_2}(\gb).\label{eq:gTildeDef}
\end{equation}
We first split the sum over $\gb$ into ideal classes $\cC\in Cl_K$. Let $\gc\in\cC$ and $\gc'=(N(\gc)/\gc)$. Since the ideals  in the set $\cA$ are principal, the ideals $\gM_0\gI\ga\c$ and $\gb\gc'$ are principal. Therefore they are respectively of the form
$(\alpha), (\beta)$ with $\gM_0\gI\gc | (\alpha )$, $\gc'|(\beta)$ with $V\alpha = a_1\nu_1+a_2\nu_2+a_3\nu_3+a_4\nu_4$, $V\beta =b_1\nu_1+b_2\nu_2+b_3\nu_3+b_3\nu_4$,
where $a_1,a_2,a_3,b_1,b_2,b_3,b_4\in\Z$ and with $\a,\b$ lying in the fundamental domain $\cD$. We will write $\a =(a_1,a_2,a_3,a_4)$, $\b=(b_1,b_2,b_3,b_4)$.
In order to handle the modulo $m$ condition  between $\gb$ and $\gI\ga$ we plit the sums according to some congruence classes on $\alpha$, $\beta$ modulo $m'$. Together this gives
\begin{equation}
T_1(\cR)=\sum_{\cC\in Cl_K}\sum_{\substack{{\a_0,\b_0 \Mod{m'}}\\ {N(\gc )(\a_0\diamond \b_0)_i\equiv (\v_0)_i\Mod {m'},\ {\rm for}\ i=1,2,3,4}}}\tilde T_\gc(\cR,\a_0,\b_0),\label{eq:T1}
\end{equation}
with $(a_0)_4=0$ since $(\a\diamond\b )_4=0$ and
$\gc\in\cC$ is a well chosen representant, and $\gc'$ as above
\begin{equation*}
\tilde T_\gc(\cR,\a_0,\b_0)=\sum_{\substack{{p\in [P_1,P_2]}\\ {p\equiv 1\Mod{D_f}}}}\sum_{\gI\in\cI}\sum_{\substack{{\a\equiv\a_0\Mod{m'}}\\ {\b\equiv \b_0\Mod {m'}}\\ {\gM_0\gI\gc|(\alpha ), \gc'| (\beta)}\\ {(\alpha\beta)/(N(\gc ))\in\cAI ( p)}}}
\1_{\cR_1}(\frac{(\alpha )}{\gM_0\gI\gc})\tilde g ((\beta)/\gc)),
\end{equation*}
with now $\cAI (p)=\cAI (\cX,\zero, 1, p)$.

We recall that our previous conditions imply that there exists $A$, $B$ such that
$N( \ga)\in [A^4,2A^4]$, $N(\gb) \in [B^4,2B^4]$.

We will use the notation of
\cite[p. 80 and 71]{May15b}:
\begin{align}
\cR_{X_0}&:=\Bigl\{ \x\in\R^4 : x_i\in [X_i, X_i (1+\eta_1)], i=1,2,3, \ x_4=0,\nonumber\\
&\qquad\qquad N(\sum_{i=1}^3x_i\nu_i)\in [X_0^4,X_0^4(1+\eta_2)]\Bigr\},\label{defRb1b2}\\
\cR_{\b_1 ,\b_2} &:=\Bigl\{ \a\in\R^4 : \| a\| \in [A,2A], \a\diamond\b_1\in\cR_{X_0},\ \a\diamond\b_2\in\cR_{X_0}\Bigr\}.\nonumber
\end{align}

Let $\cF$ be a fundamental domain such that if $\1_{\cR_1} (\ga)=1$ and $\ga\gI=V^{-1}\sum_{i=1}^4 a_i\nu_i$  then if $\alpha\in  \cF$, $a_i\ll A$ and similarly, $b_i\ll B$ for all $1\le i\le 4$.

We will concentrate on ideals $\gb$ with not too many divisors. For this we introduce a slight variant of $\tilde g$
\begin{equation*}
\1_{\cR_2}(\gb)-\tilde\1_{\cR_2}(\gb) &\text{if}\ \tau (\gb )\le \varepsilon_0^{-2},\\
0 & \text{otherwise}.
\end{cases}
\end{equation*}

Following \cite[section 11]{May15b} except that we apply Lemma \ref{div} , we prove that we can replace $\tilde g_\b$ by $g_\b$ with a  error term less
$O(\varepsilon_0^2X_0^3 (\log X)^{O(1)})$.
This modification will permit us to bound the terms $g_\b$ by $O(\varepsilon^{-2})$.

Thus now we have to concentrate on sums
\begin{equation}
T_\gc(\cR,\a_0,\b_0)=\sum_{\substack{{p\in [P_1,P_2]}\\ {p\equiv 1\Mod{D_f}}}}\sum_{\gI\in\cI}\sum_{\substack{{\a\equiv\a_0\Mod{m'}}\\ {\b\equiv \b_0\Mod {m'}}\\ {\gM_0\gI\gc|(\alpha ), \gc'| (\beta)}\\ {\gI(\alpha\beta)/(N(\gc ))\in\cAI(p)}\\
\a\diamond\b\in\cR_{X_0}}}\1_\cF (\ga)
\1_{\cR_1}(\frac{(\alpha )}{\gM_0\gI\gc}) g_{(\beta)/\gc}.
\label{eq:Tc}
\end{equation}
\subsection{Cosmetic reductions}\label{sec:Cosmetic}

For $T>0$, we denote by
$\cC_T$  the subset of $\R^4$ defined by
$$\cC_T=\{ \a\in\R^4 : N(\ga)\in [T^4,T^4(1+\eta_\cX^2)]\}.$$
By Weber's Theorem [19], we have $$|\cC_T|= \lambda_K T^4\eta_\cX^2+ O(T^3),$$
for some $\lambda_K$ depending only on $K$.
It will make some later technicalities simpler if we introduce the restriction $p\nmid N(\bb)$ to the terms in $T_1$. By Proposition \ref{prpstn:TypeI} and the divisor bound, we can do this at the cost of an error term of size
\[
\ll\sum_{p\in [P_1,P_2]}
\sum_{\substack{{\b\in \Z^4\cap C_B}\\ {N(\gb)\equiv 0\Mod p}}}\sum_{\substack{{\gb\gu\in \cAI (0,1,p)}}}X^\varepsilon\ll X^\varepsilon(X^{3}P_1^{-1}+X^2B^{4/3}P_2^2+B^4P_2^5).
\]
This is acceptably small provided
\begin{equation}
\end{equation}
When $p\equiv 1\Mod{D_f}$, the function $f\Mod{p}$ factors as the product of two linear factors. Thus the condition $p| f(\aa\diamond \bb)$ is equivalent to $p|\vv_p\cdot(\aa\diamond\bb)$ or $p|\ww_p\cdot(\aa\diamond\bb)$ for two non-zero vectors $\vv_p,\ww_p\in \ZZ^4$. There are $O(p^5)$ choices of $\aa_p,\bb_p\Mod{p}$ such that $(\aa_p\diamond\bb_p)=\v_p\cdot(\aa_p\diamond\bb_p)=w_p\cdot(\aa_p\diamond\bb_p)$ whenever $p$ is sufficiently large in terms of $f$. Therefore, as above, provided \eqref{eq:BSize} holds, the contribution of the $\aa$, $\bb$ such that
$p|\vv_p\cdot(\aa\diamond\bb)$ and  $p|\ww_p\cdot(\aa\diamond\bb)$ is bounded by
\[ X^\varepsilon\sum_{p\in [P_1,P_2]}\sum_{\substack{\a_p,\b_p\in \{ 1,\ldots ,p\}^4\\ {(\a\diamond\b )_4\equiv 0\Mod p}\\ {p|\v_p\cdot (\a\diamond\b)}\\ {p|\w_p\cdot (\a\diamond\b)}}}
\sum_{\substack{{\b\in\Z^4\cap C_B}\\ {\b\equiv\b_p\Mod p}}}\sum_{\substack{{\gu\in\cAI (0,1,p)}\\ {\gb |\gu }\\ {\u\equiv (\a_p\diamond\b_p)\Mod p}}}1
\ll X^{3+\varepsilon}P_1^{-1}.
\]
Putting this together, we see that it suffices for us to estimate for each $C\in Cl_K$ and each $\aa_0,\bb_0 \Mod{m'}$ the sums
\begin{equation}
T_3(\mathcal{R}):=\sum_{\substack{p\in [P_1,P_2]\\ p\equiv 1\Mod{D_f}}}\sum_{\gI\in\cI}\sum_{\substack{\bb\in\ZZ^4\cap \Cc_B\\ \bb\equiv \bb_0\Mod{m'} \\ p\nmid N(\bb)}}\sum_{\substack{\aa\in\ZZ^4\cap \Cc_A\\ (\aa\diamond \bb)\in\cR_{X_0}\\ p|\vv_p\cdot (\aa\diamond\bb) \\ \aa\equiv \aa_0\Mod{m'} \\
{\gI\gc |\ga }\\ \ga\in\cAI (p)}}\1_{\Rc_1}(\frac{\ga}{\gM_0\gI\gc})g_{(\beta)/\gc}.
\label{eq:T3Def}
\end{equation}
\subsection{Dispersion method}
We swap the order of summation, and apply Cauchy-Schwarz. The ideals $\gI$ and $\ga/\gI$ are coprime since $N(\gI)<X^{\theta_i}$ for all $1\le i\le\ell$.
In the application of Cauchy-Schwarz we can group these ideals together. We recall that the set $\cR_X$
is defined in \eqref{setN}.
This gives
\[
T_3^2\le \eta^4 A^4  \sum_{\substack{\aa\in\mathbb{Z}^4\cap \Cc_A\\ \aa\equiv \aa_0\Mod{m'} }}\Bigl(\sum_{\substack{p\in [P_1,P_2]\\ p\equiv 1\Mod{D_f} }}\sum_{\substack{\bb\in \ZZ^4\cap\Cc_B\\
\aa\diamond\bb\in\cR_{X_0}\\ p|\vv_p\cdot (\aa\diamond \bb)\\ \bb\equiv \bb_0\Mod{m'}\\ p\nmid N(\bb)}}g_\bb\Bigr)^2.
\]
Thus we see that
\begin{align}
T_3^2\ll \eta_\cX^2 A^4 T_4\label{eq:T3}
\end{align}
where, with the notation \eqref{defRb1b2}
\[
T_4:=\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f} }}\sum_{\substack{\bb_1,\bb_2\in \ZZ^4\cap\Cc_B\\ \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'}\\ p_1\nmid N(\bb_1),\, p_2\nmid N(\bb_2)}}g_{\bb_1}g_{\bb_2}\sum_{\substack{\aa\in \ZZ^4\cap \Cc_A\\ \aa\in\cR_{\b_1,\b_2}\\
p_1|\vv_{p_1}\cdot (\aa \diamond \bb_1)\\ p_2|\vv_{p_2}\cdot (\aa\diamond \bb_2)}}1.
\]
Thus we wish to show that $T_4=o(\eta_\cX^6 A^2 B^6)$.
\subsection{Collinear $\bb_1,\bb_2$}
We separate the situation when $\bb_1$ and $\bb_2$ are collinear (in which case we have $\wedge(\bb_1,\bb_2)=0$ where $\wedge(\xx,\yy)$ is the $L^2$ norm of the six $2\times 2$ subdeterminants of the $2\times 4$ matrix with columns $\xx$ and $\yy$. Thus we have
\begin{equation}
\end{equation}
where $T_5$ is those terms with $\wedge(\bb_1,\bb_2)=0$ and $T_6$ is those terms with $\wedge(\bb_1,\bb_2)\ne 0$.

We first concentrate on $T_5$.
\begin{lmm}\label{lmm:T5}
\[
T_5\ll A^3 B^3 (\log{X})^{O(1)}.
\]
\end{lmm}
\begin{proof}
Let $\cc$ be the shortest non-zero vector with integer components which is collinear with $\bb_1$ (this is $\bb_1$ divided by the $\gcd$ of its components). Then we see that $\bb_1=\lambda_1\cc$ for some $\lambda\in \ZZ$, and since $\bb_2$ is collinear with $\bb_1$, we also have that $\bb_2=\lambda_2\cc$ for some $\lambda_2\in \mathbb{Z}$. Thus we see that
\[
T_5\ll \sum_{\substack{\cc\in \ZZ^4\\ \|\cc\|\ll B}}\sum_{\lambda_1,\lambda_2\ll B/\|\cc\|}\sum_{\substack{\aa\in \ZZ^4\cap\Cc_A\\ (\aa\diamond \cc)_4=0}}\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1|f(\lambda_1\aa\diamond \cc)\\ p_2|f(\lambda_2\aa\diamond\cc)}}1.
\]
We see that the inner sum is $O(1)$ since $P_1\gg B^\epsilon$ and $f(\lambda_1\aa\diamond\cc)\ll B^{O(1)}$. We then split the size of $\|\cc\|$ into dyadic ranges, giving
\[
T_5\ll (\log{X})\sup_{C\ll B}\frac{B^2}{C^2}\sum_{\substack{\cc\in \ZZ^4\\ \|\cc\|\asymp C}}\sum_{\substack{\aa\in \ZZ^4\cap\Cc_A\\ (\aa\diamond \cc)_4=0}}1.
\]
We now let $\zz=(\aa\diamond\cc)$. By the divisor bound, given $\zz$ there are $O(\tau_K(\mathfrak{z}))$ choices of $\aa,\cc$. Thus we see that
\[
T_5\ll (\log{X})\sup_{C\ll B} \frac{B^2}{C^2}\sum_{z_1,z_2,z_3\ll AC}\tau_K(z_1\nu_1+z_2\nu_2+z_3\nu_3)\ll A^3B^3(\log{X})^{O(1)}.
\]
\end{proof}
Thus we are left to bound $T_6$.
\subsection{Lattice counts}
We now concentrate on the inner sum. Let $\Lambda_{\bb_1,\bb_2}$ and $\Lambda_{\bb_1,\bb_2,p_1,p_2}$ denote the lattices
\begin{align*}
\Lambda_{\bb_1,\bb_2}&:=\{\xx\in\ZZ^4:\,(\xx\diamond \bb_1)_4=(\xx\diamond \bb_2)_4=0\},\\
\Lambda_{\bb_1,\bb_2,p_1,p_2}&:=\{\xx\in\Lambda_{\bb_1,\bb_2}:\,p_1|\vv_{p_1}\cdot (\xx\diamond \bb_1),\,p_2|\vv_{p_2}\cdot (\xx \diamond \bb_2)\}.
\end{align*}
Thus the inner sum in $T_6$ is
\[
\sum_{\substack{\aa \in \Cc_A\cap\Lambda_{\bb_1,\bb_2,p_1,p_2}\\
\a\in\cR_{\b_1 ,\b_2}\\
\]
If $\bb_1,\bb_2$ are not collinear, then $\Lambda_{\bb_1,\bb_2}$ is a lattice of rank 2, and so it has a Minkowski-reduced basis $\{\zz_1,\zz_2\}$. Without loss of generality we may assume that $\|\zz_1\|\le \|\zz_2\|$. Thus we have that
\[
\sum_{\aa \in \Cc_A\cap\Lambda_{\bb_1,\bb_2,p_1,p_2}\cap\cR_{\b_1 ,\b_2}}1=\sum_{\substack{\lambda_1,\lambda_2\in\mathbb{Z}\\ \lambda_1\zz_1+\lambda_2\zz_2\in\Cc_A\cap\cR_{\b_1 ,\b_2}\\
\lambda_1 c_1+\lambda_2 c_2\equiv 0\Mod{p_1}\\ \lambda_1c_3+\lambda_2c_4\equiv 0\Mod{p_2} }}1,
\]
for some constants $c_1,c_2,c_3,c_4$ depending only on $\bb_1,\bb_2$, $p_1$ and $p_2$. The condition $\lambda_1\zz_1+\lambda_2\zz_2\in\Cc_A\cap\cR_{\b_1,\b_2}$ forces $\lambda_1,\lambda_2$ to lie in a region $\Rc'_{\bb_1,\bb_2}\subseteq \RR^4$. Since $\|\lambda_1\zz_1+\lambda_2\zz_2\|\asymp |\lambda_1|\|\zz_1\|+|\lambda_2|\|\zz_2\|$ and $\Cc_A$ only contains vectors of norm $O(A)$, we see that lying in $\Rc_{\bb_1,\bb_2}$ forces $\lambda_1\ll A/\|\zz_1\|$ and $\lambda_2\ll A/\|\zz_2\|$, so $\Rc'_{\bb_1,\bb_2}$ has volume $O(A^2/\|\zz_1\|\|\zz_2\|)$.

By Davenport's Theorem on counting lattice points (\cite[Lemma 7.1]{May15b} for example), we have that
\[
\sum_{\substack{(\lambda_1,\lambda_2)\in \Rc'_{\bb_1,\bb_2} \\ \lambda_1c_1+\lambda_2c_2=0\Mod{[p_1,p_2]} }}1=\frac{\vol(\Rc'_{\bb_1,\bb_2})}{f_{\bb_1,\bb_2,p_1,p_2}}+O\Bigl(\frac{A}{\|\zz_1\|}\Bigr)
\]
where $f_{\bb_1,\bb_2,p_1,p_2}=[\Lambda_{\bb_1,\bb_2}:\Lambda_{\bb_1,\bb_2,p_1,p_2}]$ is the index of the lattices, given explicitly in terms of $c_1,c_2,c_3,c_4,p_1,p_2$ by
\[
\begin{cases}
1,\qquad &c_1\equiv c_2\equiv 0\Mod{p_1}\text{ and }c_3\equiv c_4\equiv 0\Mod{p_2},\\
p_2,&c_1\equiv c_2\equiv 0\Mod{p_1}\text{ and }c_3,c_4\text{ not both }0\Mod{p_2},\\
p_1,&c_3\equiv c_4\equiv 0\Mod{p_2}\text{ and }c_1,c_2\text{ not both }0\Mod{p_1},\\
p_1, &p_1= p_2\text{ and }c_1c_4\equiv c_2c_3\Mod{p_1}\text{ and }c_1,c_2\text{ not all }0\Mod{p_1},\\
\end{cases}
\]
We split $T_6$ into the contribution from the main term $\vol(\Rc'_{\bb_1,\bb_2})/f_{\bb_1,\bb_2,p_1,p_2}$ and the error term $O(A/\|\zz_1\|)$. This gives
\begin{equation}
\end{equation}
\begin{align*}
T_7&:=\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f} }}\sum_{\substack{\bb_1,\bb_2\in \ZZ^4\cap\Cc_B\\ \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'}\\ p_1\nmid N(\bb_1),\,p_2\nmid N(\bb_2)\\\wedge(\bb_1,\bb_2)\ne 0}}\frac{A}{\|\zz_1\|},\\
T_8&:=\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f} }}\sum_{\substack{\bb_1,\bb_2\in \ZZ^4\cap\Cc_B\\ \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'}\\ p_1\nmid N(\bb_1),\,p_2\nmid N(\bb_2)\\\wedge(\bb_1,\bb_2)\ne 0}}\frac{g_{\bb_1}g_{\bb_2}\vol(\Rc'_{\bb_1,\bb_2})}{f_{\bb_1,\bb_2,p_1,p_2}}.
\end{align*}
We first show that the contribution $T_7$ from the error term is small.
\begin{lmm}\label{lmm:T7}
\[
T_7\ll AB^7 P_2^2.\]
\end{lmm}
\begin{proof}
We note that $\zz_1\in \ZZ^4$ with $\|\zz_1\|^2\le \|\zz_1\|\cdot\|\zz_2\|\ll \det(\Lambda_{\bb_1,\bb_2})\ll B^2$. Thus $\|\zz_1\|\ll B$. Thus we can rearrange the summation to give
\[
T_7 \ll P_2^2\sum_{\bb_1,\bb_2\in \ZZ^4\cap \Cc_B}\frac{A}{\|\zz_1\|}\ll A P_2^2\sum_{\substack{\zz_1\in\ZZ^4\\ \|\zz_1\|\ll B}}\frac{1}{\|\zz_1\|}\Bigl(\sum_{\substack{\bb\in \ZZ^4\cap\Cc_{B}\\ (\bb\diamond \zz_1)_4=0}}1\Bigr)^2
\]
The condition $(\bb\diamond \zz_1)_4=0$ forces $\bb$ to lie in a rank 3 lattice of determinant $\|\zz_1\|$. Thus the inner sum is $O(B^3/\|z_1\|+B^2)$. Thus we obtain the bound
\[
T_7 \ll A P_2^2\sum_{\substack{\zz_1\in\ZZ^4\\ \|\zz_1\|\ll B}}\Bigl(\frac{B^6}{\|\zz_1\|^3}+\frac{B^4}{\|\zz_1\|}\Bigr)\ll AB^7 P_2^2.
\]
This gives the result.
\end{proof}
Thus we are left to show that
\[
T_8=o(\eta_\cX^4 A^2 B^6).
\]
\subsection{Further lattice estimates}
We recall that $\Rc'_{\bb_1,\bb_2}$ is the region $\lambda_1,\lambda_2\in \RR^2$ such that $\lambda_1\zz_1+\lambda_2\zz_2\in \Cc_B\cap\cR_{\b_1 ,\b_2}$. We see that this has volume $\vol(\Rc''_{\bb_1,\bb_2})/\det(\Lambda_{\bb_1,\bb_2})$, where $\det(\Lambda_{\bb_1,\bb_2})$ is the determinant of the lattice (that is, the 2-dimensional area of parallelogram generated by $\zz_1,\zz_2$) and $\Rc''_{\bb_1,\bb_2}$ is the 2-dimensional region formed by intersecting $\Cc_B$ with the $\zz_1,\zz_2$ plane
\[T_8=
\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\sum_{\substack{\bb_1,\bb_2\in \ZZ^4\cap\Cc_B\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'} \\ \wedge(\bb_1,\bb_2)\ne 0\\ p_1\nmid N(\bb_1),\,p_2\nmid N(\bb_2)}}\frac{g_{\bb_1}g_{\bb_2}\vol(\Rc''_{\bb_1,\bb_2})}{f_{\bb_1,\bb_2,p_1,p_2}\det(\Lambda_{\bb_1,\bb_2})}.
\]
We first establish a few simple estimates.
\begin{lmm}
\[
\sum_{\substack{p_1,p_2\in[P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f} }}\frac{\vol(\Rc_{\bb_1,\bb_2})}{f_{\bb_1,\bb_2,p_1,p_2}}\ll \vol(\Rc'_{\bb_1,\bb_2})+O\Bigl(\frac{AP_2^2}{\|\zz_1\|}\Bigr).
\]
\end{lmm}
\begin{proof}
We have that
\begin{align*}
\sum_{\substack{p_1,p_2\in[P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\sum_{\substack{\aa\in \ZZ^4\cap \Cc_A\\ \aa\in\cR_{\b_1 ,\b_2}\\ p_1|\vv_{p_1}\cdot \aa\diamond \bb_1\\ p_2|\vv_{p_2}\cdot \aa \diamond\bb_2}}1&=\sum_{\substack{\aa\in \ZZ^4\cap \Cc_A\\ \aa\in\cR_{\b_1 ,\b_2}}}\sum_{\substack{p_1,p_2\in[P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}\\ p_1|\vv_{p_1}\cdot \aa\diamond \bb_1\\ p_2|\vv_{p_2}\cdot \aa \diamond\bb_2}}1\\
&\ll \sum_{\substack{\aa\in \ZZ^4\cap \Cc_A\\ (\aa\in\cR'_{\b_1 ,\b_2}=0}}1\\
&\ll \vol(\Rc'_{\bb_1,\bb_2})+O\Bigl(\frac{A}{\|\zz_1\|}\Bigr).
\end{align*}
On the other hand, we know that
\[
\sum_{\substack{p_1,p_2\in[P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\sum_{\substack{\aa\in \ZZ^4\cap \Cc_A\\ \aa\in\cR_{\b_1 ,\b_2}\\ p_1|\vv_{p_1}\cdot \aa\diamond \bb_1\\ p_2|\vv_{p_2}\cdot \aa \diamond\bb_2}}1=\sum_{\substack{p_1,p_2\in[P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\Bigl(\frac{\vol(\Rc'_{\bb_1,\bb_2})}{f_{\bb_1,\bb_2,p_1,p_2}}+O\Bigl(\frac{A}{\|\zz_1\|}\Bigr)\Bigr).
\]
Putting these together gives the result.
\end{proof}
\begin{lmm}\label{lmm:Cylinder}
\[
\Cc_{C,d;\cc_1,\bb_2}:=\#\Bigl\{\bb_1\in\ZZ^4\cap\Cc_B:\,\wedge(\bb_1,\bb_2)\sim \frac{B^2}{C},\,\bb_1\equiv \cc_1\Mod{d}\Bigr\}.
\]
Then we have
\[
\#\Cc_{C,d;\cc_1,\cc_2}\ll \Bigl(1+\frac{B}{d}\Bigr)\Bigl(1+\frac{B}{C d}\Bigr)^3.
\]
\end{lmm}
\begin{proof}
The condition $\wedge(\bb_1,\bb_2)\sim B^2/C$ forces $\bb_1$ to lie in a cylinder $\Cc$ with axis of length $O(B)$ proportional to $\bb_2$, and with radius $O(B/C)$. We then see that we can cover this cylinder with
\[
\ll \Bigl(1+\frac{B}{d}\Bigr) \Bigl(1+\frac{B}{Cd}\Bigr)^3
\]
different hypercubes $\Bc$ of side length $d$. Finally, there is at most one choice of $\bb_1$ in a hypercube $\Bc$ of side length $d$ which satisfies $\bb_1\equiv \cc_1\Mod{d}$, which gives the result.
\end{proof}

For any $\cc_1,\cc_2\in\Z^4$, the notation $\cc_1\propto\cc_2$ indicates that the two vectors are proportional.
\begin{lmm}\label{lmm:BasicSum}
If $\cc_1\not\propto\cc_2\Mod{p}$ then
\[
\sum_{\substack{\bb_1,\,\bb_2\in \ZZ^4\cap\Cc_B \\ \wedge(\bb_1,\bb_2)\ne 0\\ \mathrm{primitive}\\ \bb_1\equiv \cc_1\Mod{p}\\ \bb_2\equiv \cc_2\Mod{p}}}\frac{1}{\det(\Lambda_{\bb_1,\bb_2})}\ll \frac{B^6}{p^8}+B^{17/3}.
\]
\end{lmm}
\begin{proof}
We recall that $\Lambda_{\bb_1,\bb_2}$ is the lattice in $\ZZ^4$ of $\xx$ with $(\xx\diamond\bb_1)_4=(\xx\diamond\bb_2)_4=0$. By \cite[Lemma 10.1]{May15b}, this has determinant $\wedge(\bb_1,\bb_2)/D_{\bb_1,\bb_2}$, where $\wedge(\bb_1,\bb_2)$ is the $L^2$ norm of the six $2\times 2$ subdeterminants of the matrix with columns $\bb_1,\bb_2$, and $D_{\bb_1,\bb_2}$ is the greatest common divisor of these six subdeterminants. Note that this implies $\bb_1\propto\bb_2\Mod{D_{\bb_1,\bb_2}}$, so since $\bb_1,\bb_2$ are primitive we must have $D_{\bb_1,\bb_2}\le B$ when $\wedge(\bb_1,\bb_2)\ne 0$.

We consider separately those $\bb_1,\bb_2$ with $\wedge(\bb_1,\bb_2)\ll B$, those with $B\ll \wedge(\bb_1,\bb_2)\ll B^{4/3}$, and those $\bb_1,\bb_2$ with
\[
D_{\bb_1,\bb_2}=d,\qquad \wedge(\bb_1,\bb_2)\sim B^2/C\]
for each $1\le d\le B$ and $1\le C\le B^{2/3}$ with $C$ running through powers of $2$.

If $\wedge(\bb_1,\bb_2)\ll B$ then $\bb_1$ lies within $O(1)$ of the line proportional to $\bb_2$, and so there are $O(B)$ choices of $\bb_1$. Since $\det(\Lambda_{\bb_1,\bb_2})\ge 1$, these terms contribute a total (ignoring the congruence conditions $\Mod{p}$ for an upper bound)
\[
\ll \sum_{\|\bb_2\|\ll B}O(B)\ll B^5.
\]
If $\wedge(\bb_1,\bb_2)\in[B, B^{4/3}]$ then we separately consider those with $\wedge(\bb_1,\bb_2)\sim B^2/C$ for $C\in[B^{2/3},B]$ running through powers of 2, and again drop the congruence constraints. By Lemma \ref{lmm:Cylinder} there are
\[
\ll B\Bigl(1+\frac{B}{C}\Bigr)^3\ll \frac{B^4}{C^3}
\]
choices of $\bb_1$ given $\bb_2$. If $\wedge(\bb_1,\bb_2)\sim B^2/C$ then $\det(\Lambda_{\bb_1,\bb_2})\ge B/C$ (since $D_{\bb_1\bb_2}\le B$). Thus these terms contribute
\[
\ll \sum_{C=2^j\in[B^{2/3},B]}\sum_{\substack{\bb_2\in \ZZ^4\cap\Cc_B}}\frac{C}{B}\frac{B^4}{C^3 }\ll B^{17/3}.
\]

Thus we are left to consider the terms with $\wedge(\bb_1,\bb_2)\sim B^2/C$ for some $C\le B^{2/3}$. The condition $D_{\bb_1,\bb_2}=d$ forces $\bb_1\propto \bb_2\Mod{d}$, and so $\bb_1\equiv \lambda \bb_2\Mod{d}$ for some $\lambda\in \{1,\dots,d\}$. Since $\cc_1\not\propto\cc_2\Mod{p}$, we see $p\nmid d$. Thus $\bb_1\equiv \cc_0(\lambda)\Mod{dp}$, where $\cc_0(\lambda)\equiv \lambda\bb_2\Mod{d}$ and $\cc_0(\lambda)\equiv \cc_1\Mod{p}$. By Lemma \ref{lmm:Cylinder}, the number of choices of $\bb_1$ is therefore
\[
\ll \sum_{1\le \lambda\le d}\#\Cc_{C,pd,\cc_0(\lambda),\bb_2}\ll d\Bigl(1+\frac{B}{p d}\Bigr)\Bigl(1+\frac{B}{p C d}\Bigr)^3\ll B+\frac{B^4}{p^4 C^3 d^3}.
\]
If $D_{\bb_1,\bb_2}=d$ and $\wedge(\bb_1,\bb_2)\sim B^2/C$ then $\det(\Lambda_{\bb_1,\bb_2})\gg B^2/(Cd)$. Thus we find that the contribution from terms with $\wedge(\bb_1,\bb_2)\ge B^{4/3}$ is
\begin{align*}
\sum_{\substack{\bb_1,\,\bb_2\in \ZZ^4\cap\Cc_B \\ \wedge(\bb_1,\bb_2)\ge B\\ \bb_1\equiv \cc_1\Mod{p}\\ \bb_2\equiv \cc_2\Mod{p}\\ \mathrm{primitive}}}\frac{1}{\det(\Lambda_{\bb_1,\bb_2})}&\ll \sum_{1\le d\le B}\sum_{C=2^j\ll B^{2/3}}\frac{d C}{B^2}\sum_{\substack{\bb_2\in \ZZ^4\cap\Cc_B\\ \bb_2\equiv \cc_2\Mod{p}}}\Bigl(B+\frac{B^4}{C^3 d^3 p^4}\Bigr)\\
&\ll \frac{B^6}{p^8}+B^{17/3}.
\end{align*}
Thus we have a suitable bound in each case, giving the result.
\end{proof}
\begin{lmm}\label{lmm:BasicSum2}
Let $\cc_1,\cc_2\in\ZZ^4$ be non-zero $\Mod{p}$ with $\cc_1\propto\cc_2\Mod{p}$. Then we have
\[
\sum_{\substack{\bb_1,\,\bb_2\in \ZZ^4\cap\Cc_B \\ \wedge(\bb_1,\bb_2)\ne 0\\ \mathrm{primitive}\\ \bb_1\equiv \cc_1\Mod{p}\\ \bb_2\equiv \cc_2\Mod{p}}}\frac{1}{\det(\Lambda_{\bb_1,\bb_2})}\ll \frac{B^6}{p^7}+B^{17/3}.
\]
\end{lmm}
\begin{proof}
This is similar to the proof of Lemma \ref{lmm:BasicSum}. Since the estimates in the proof of Lemma \ref{lmm:BasicSum} when $\wedge(\bb_1,\bb_2)\ll B^{4/3}$ didn't depend on whether $p|D_{\bb_1,\bb_2}$ or not, an identical argument shows that the contribution of $\bb_1,\bb_2$ with $\wedge(\bb_1,\bb_2)\ll B^{4/3}$ contributes $O(B^{17/3})$. Therefore we just need to consider the contribution when $\wedge(\bb_1,\bb_2)\gg B^{4/3}$.

We split the summation according to $\wedge(\bb_1,\bb_2)\sim B^2/C$ and $D_{\bb_1,\bb_2}=d$. Since $\cc_1\propto\cc_2\Mod{p}$, we have $\cc_1\equiv \lambda_0\cc_2\Mod{p}$ for some $\lambda_0$.  Since $\bb_1\equiv \cc_1\Mod{p}$ and $\bb_2\equiv \cc_2\mod{p}$ we then see that $p|d$. The condition $D_{\bb_1,\bb_2}=d$ forces $\bb_1=\lambda\bb_2\Mod{d}$ for some $\lambda$, with $\lambda\equiv \lambda_0\Mod{p}$. Thus, by Lemma \ref{lmm:Cylinder}, the number of choices of $\bb_1,\bb_2$ with $\wedge(\bb_1,\bb_2)\sim B^2/C$ and $D_{\bb_1,\bb_2}=d$ s
\begin{align*}
\ll \sum_{\substack{\bb_2\in \ZZ^4\cap\Cc_B\\ \bb_2\equiv \cc_2\Mod{p}}}\sum_{\substack{1\le \lambda\le d\\ \lambda\equiv \lambda_0\Mod{p}}}\#\Cc_{C,d,\lambda\bb_2,\bb_2}&\ll \Bigl(1+\frac{B^4}{p^4}\Bigr)\frac{d}{p}\Bigl(1+\frac{B}{d}\Bigr)\Bigl(1+\frac{B}{Cd}\Bigr)^3\\
&\ll \frac{B^8}{p^5 C^3 d^3}+B^5.
\end{align*}
When $\wedge(\bb_1,\bb_2)\sim B^2/C$ and $D_{\bb_1,\bb_2}=d$ we have $\det(\Lambda_{\bb_1,\bb_2})\gg B^2/(Cd)$. Thus the total contribution from terms with $\wedge(\bb_1,\bb_2)\gg B^{4/3}$ is
\begin{align*}
\sum_{\substack{d\le B\\ p|d}}\sum_{C=2^j\ll B^{2/3}}\frac{C d}{B^2}\Bigl(\frac{B^8}{p^5 C^3 d^3}+B^5\Bigr)\ll \frac{B^6}{p^7}+B^{17/3}.
\end{align*}
This gives the result.
\end{proof}
We are now able to make progress on our aim of bounding $T_8$.
\begin{lmm}\label{lmm:T8}
Let $T_8$ be as given by \eqref{eq:T6}. Then we have
\[
T_8\ll \eta_2A^2B^6+\eta_2^{-4}A^2\sup_{\cC_1,\cC_2}\Bigl(|T_{11}|+|T_{12}|\Bigr),
\]
where the supremum is over all hypercubers $\cC_1,\cC_2\subseteq \cC_B$ of side length $\eta_2B$ and
\begin{align}
T_{11}&:=\sum_{\substack{p\in [P_1,P_2]\\ p\equiv 1\Mod{D_f}}}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'} \\ \wedge(\bb_1,\bb_2)\ne 0\\ p\nmid N(\bb_1) N(\bb_2)}}\frac{g_{\bb_1}g_{\bb_2}}{f_{\bb_1,\bb_2,p,p}\det(\Lambda_{\bb_1,\bb_2})},\label{eq:T11Def}\\
T_{12}&:=\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\frac{1}{p_1 p_2}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'} \\ \wedge(\bb_1,\bb_2)\ne 0\\ p_1\nmid N(\bb_1),\,p_2\nmid N(\bb_2)}}\frac{g_{\bb_1}g_{\bb_2}D_{\bb_1,\bb_2}}{\wedge(\bb_1,\bb_2)}.\label{eq:T12Def}
\end{align}
\end{lmm}
\begin{proof}
We wish to replace $\Rc''_{\bb_1,\bb_2}$ with a quantity which doesn't depend on $\bb_1,\bb_2$ by splitting $\Cc_B$ into $O(\eta_2^{-4}\eta_1^4)$ smaller hypercubes of side length $\eta_2 B$. We see that $\vol(\Rc''_{\bb_1,\bb_2})$ depends continuously on the components of $\bb_1$ and $\bb_2$, and that $\vol(\Rc''_{\bb_1,\bb_2})$ is always of size $O(A^2)$. Moreover, if we restrict $\bb_1,\bb_2$ to hypercubes of side length $\eta_2 B$ then $\vol(\Rc'_{\bb_1,\bb_2})$ varies by $O(\eta_2 A^2)$ as $\bb_1,\bb_2$ vary within these hypercubes. Thus we see that
\begin{align}
T_8&=\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f} }}\sum_{\substack{\bb_1,\bb_2\in \ZZ^4\cap\Cc_B\\ \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'}\\ p_1\nmid N(\bb_1),\,p_2\nmid N(\bb_2)\\\wedge(\bb_1,\bb_2)\ne 0}}\frac{g_{\bb_1}g_{\bb_2}\vol(\Rc''_{\bb_1,\bb_2})}{f_{\bb_1,\bb_2,p_1,p_2}\det(\Lambda_{\bb_1,\bb_2})}\nonumber \\
&\ll T_9+\eta_2^{-4} A^2\sup_{\Cc_1,\Cc_2}|T_{10}|,
\end{align}
\begin{align*}
T_9&:=\eta_2\varepsilon_0^{-4}\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f} }}\sum_{\substack{\bb_1,\bb_2\in \ZZ^4\cap\Cc_B\\ \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'}\\ p_1\nmid N(\bb_1),\,p_2\nmid N(\bb_2)\\\wedge(\bb_1,\bb_2)\ne 0}}\frac{\vol(\Rc''_{\bb_1,\bb_2})}{f_{\bb_1,\bb_2,p_1,p_2}\det(\Lambda_{\bb_1,\bb_2})},\\
T_{10}&=T_{10}(\Cc_1,\Cc_2):= \sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m'} \\ \wedge(\bb_1,\bb_2)\ne 0\\ p_1\nmid N(\bb_1),\,p_2\nmid N(\bb_2)}}\frac{g_{\bb_1}g_{\bb_2}}{f_{\bb_1,\bb_2,p_1,p_2}\det(\Lambda_{\bb_1,\bb_2})}.
\end{align*}
By the above lemmas, we have that
\[
T_9\ll \varepsilon^{-4}\eta_2 A^2 B^6,
\]
which is acceptable if $\eta_2\ll \eta_1^9$. Thus we are left to bound $T_{10}$. We separate the terms when the two primes in the outer sum are the same. Thus
\begin{equation}
\end{equation}
where $T_{11}$ denotes the terms with $p_1=p_2$ and $T_{12}$ those terms with $p_1\ne p_2$.

$T_{11}$ clearly is equal to the expression given in the lemma, but (recalling that $\det(\Lambda_{\bb_1,\bb_2})=\wedge(\bb_1,\bb_2)/D_{\bb_1,\bb_2}$) we need to show that $f_{\bb_1,\bb_2,p_1,p_2}=p_1p_2$ in $T_{12}$ to obtain the desired expression. We first note that since $p_1\nmid N(\bb_1)$ the multiplication-by-$\bb_1$  matrix $M_{\bb_1}$ is invertible $\Mod{p_1}$. This means that for every $\xx\Mod{p_1}$ there is a unique $\aa\Mod{p_1}$ such that $\xx=\aa\diamond \bb_1\Mod{p_1}$ , and so $\vv_{p_1}\cdot (\aa\diamond\bb_1)=0\Mod{p_1}$ is therefore a non-trivial constraint on the components of $\aa\Mod{p_1}$. Similarly since $p_2\nmid N(\bb_2)$, we see $p_2|\vv_{p_2}\cdot(\aa\diamond\bb_2)$ is a non-trivial constraints on the components of $\aa\Mod{p_2}$. From this it follows that we have that $f_{\bb_1,\bb_2,p_1,p_2}=p_1p_2$, and so $T_{12}$ is given by the expression in the lemma.
\end{proof}
First we concentrate on $T_{11}$.
\subsection{The case $p_1=p_2$}
In this section we wish to bound the sum $T_{11}$ from \eqref{eq:T11Def}. We first see by Lemma \ref{lmm:BasicSum2} the contribution of terms with $\bb_1\propto \bb_2\Mod{p}$ to $T_{11}$ is
\begin{align*}
\ll \sum_{p\in[P_1,P_2]}\sum_{\cc_1\propto\cc_2\Mod{p}}\Bigl(\frac{B^6}{p^7}+B^{17/3}\Bigr)\ll \frac{B^6}{P_1}+P_2^6 B^{17/3}.
\end{align*}
Thus we have
\[
T_{11}=T_{11}'+O\Bigl(\frac{B^6}{P_1}+P_2^6 B^{17/3}\Bigr),
\]
where $T_{11}'$ counts those terms in $T_{11}$ with $\bb_1\not\propto \bb_2\Mod{p}$, or equivalently with $p\nmid D_{\bb_1,\bb_2}$.

When $\bb_1\not \propto\bb_2\Mod{p}$, we see that the constraints $(\aa\diamond\bb_1)_4=0\Mod{p}$ and $(\aa\diamond\bb_2)_4=0\Mod{p}$ are two linearly independent linear constraints on $\aa\Mod{p}$. In  particular, the index $f_{\bb_1,\bb_2,p,p}=[\Lambda_{\bb_1,\bb_2}:\Lambda_{\bb_1,\bb_2,p,p}]$ simplifies to give
\[
\frac{1}{f_{\bb_1,\bb_2,p,p}}= \frac{\#\{\aa\Mod{p}:\,(\aa\diamond\bb_1)_4=(\aa\diamond\bb_2)_4=\vv\cdot(\aa\diamond \bb_1)=\vv\cdot(\aa\diamond\bb_2)=0\Mod{p}\}}{p^2}.
\]
We separate the above count according to the rank  of the multiplication-by-$\aa$ matrix $M_a\Mod{p}$. Thus
\begin{equation}
\frac{1}{f_{\bb_1,\bb_2,p,p}}=\sum_{i=0}^4\frac{1}{p^2}\widetilde{S}_i(\bb_1,\bb_2),
\label{eq:ftoS}
\end{equation}
where $\widetilde{S}_i(\bb_1,\bb_2)$ counts those $\aa\Mod{p}$ such that $M_\aa$ has rank $i$ and satisfies $(\aa\diamond\bb_1)_4=(\aa\diamond\bb_2)_4=\vv\cdot(\aa\diamond \bb_1)=\vv\cdot(\aa\diamond\bb_2)=0\Mod{p}$.

First we consider $\widetilde{S}_4$.
\begin{lmm}\label{lmm:S4t}
\[
\sum_{\cc_1,\cc_2\Mod{p}}\frac{1}{p^2}\widetilde{S}_4(\cc_1,\cc_2)\ll p^6.
\]
\end{lmm}
\begin{proof}
In this case $M_{\aa}$ has rank 4, and so is invertible $\Mod{p}$. Given any choice of $\cc_1\Mod{p}$ with $p\nmid N(\cc_1)$, we see that $\aa\diamond\cc_1=M_{\cc_1}\aa$ where the multiplication-by-$\cc_1$ matrix $M_{\cc_1}$ has determinant $N(\cc_1)$, and so is invertible $\Mod{p}$. Therefore, given any choice of $\xx\Mod{p}$, there is a unique choice of $\aa\Mod{p}$ with $p\nmid N(\aa)$ such that $\aa\diamond\cc_1\equiv \xx\Mod{p}$. Similarly, since we only consider $\aa$ with $M_\aa$ is invertible, given any choice of $\yy\Mod{p}$ there is then a unique choice of $\cc_2\Mod{p}$ such that $\aa\diamond \cc_2\equiv \yy\Mod{p}$. Since there are $O(p^4)$ choices of $\xx,\yy\Mod{p}$ with $\xx_4=\yy_4=0$ and $\vv\cdot\xx=\vv\cdot\yy=0\Mod{p}$, there are therefore $O(p^4)$ choices of $\aa,\cc_2\Mod{p}$ such that $p\nmid N(\aa)$ and $(\aa\diamond\cc_1)_4=(\aa\diamond\cc_2)_4=\vv\cdot(\aa\diamond\cc_1)=\vv\cdot(\aa\diamond\cc_2)=0\Mod{p}$. Thus we have that
\[
\sum_{\cc_1,\cc_2\Mod{p}}\frac{1}{p^2}\widetilde{S}_4(\cc_1,\cc_2)\ll p^6,
\]
as required.
\end{proof}
Now we consider $\widetilde{S}_2$ and $\widetilde{S}_3$.
\begin{lmm}\label{lmm:S23}
\[
\sum_{\cc_1,\cc_2\Mod{p}}\frac{1}{p^2}\Bigl(\widetilde{S}_2(\cc_1,\cc_2)+\widetilde{S}_3(\cc_1,\cc_2)\Bigr)\ll p^6.
\]
\end{lmm}
\begin{proof}
Since $M_\aa$ is not invertible $\Mod{p}$ and has determinant $N(\aa)$, we see that $p|N(\aa)$ and so $p|N(\aa\diamond\cc_1)=N(\aa)N(\cc_1)$. Since $f(x_1,x_2,x_3)$ is an irreducible polynomial which splits into two linear factors over a quadratic extension, and $N(x_1\nu_1+x_2\nu_2+x_3\nu_3)$ is a quartic irreducible polynomial which has no linear factors over any quadratic extension, these polynomials have no common polynomial factors over a mutual splitting field, and so define an algebraic variety of codimension 2. Thus (by Hilbert's Theorem 90 and the Lang-Weil bound) there are $O(p)$ choices of $(x_1,x_2,x_3)\Mod{p}$ such that $f(x_1,x_2,x_3)=N(x_1\nu_1+x_2\nu_2+x_3\nu_3)=0\Mod{p}$. Thus there are $O(p^2)$ choices of $\xx,\yy$ with $p|N(\xx),N(\yy)$ and $x_4=y_4=\vv\cdot\xx=\vv\cdot\yy=0\Mod{p}$. Given $\cc_1$ with $p\nmid N(\cc_1)$ and $\xx$ and $\yy$ as above, here is a unique $\aa\Mod{p}$ such that $\aa\diamond\cc_1\equiv \xx\Mod{p}$, and there are $O(p^2)$ choices of $\cc_2$ such that $\aa\diamond \cc_2\equiv \yy\Mod{p}$ provided $M_\aa$ has rank $2$ or $3$. Putting this together gives the result.
\end{proof}
\begin{lmm}\label{lmm:S0}
\[
S_0(\cc_1,\cc_2)\ll 1.
\]
\end{lmm}
\begin{proof}
The only $\aa$ such that $M_\aa$ has rank 0 is the vector $\mathbf{0}\Mod{p}$.
\end{proof}
Finally, we need to consider the situation where $M_{\aa}$ has rank 1, which is slightly more complicated.
\begin{lmm}\label{lmm:S1}
\[ \sum_{\cc_1,\cc_2 \Mod{p}}\frac{1}{p^2}\widetilde{S}_1(\cc_1,\cc_2)\ll p^6.
\]
\end{lmm}
\begin{proof}
If $M_\aa$ has rank 1, then there are $p^3$ choices of $\bb\Mod{p}$ such that $M_\aa \bb=\mathbf{0}\Mod{p}$. On the other hand, let $\af=(a_1\nu_1+a_2\nu_2+a_3\nu_3+a_4\nu_4)$ and $\bfr=(b_1\nu_1+b_2\nu_2+b_3\nu_3+b_4\nu_4)$. If $M_{\aa}\bb=\mathbf{0}\Mod{p}$, then the ideal $\af\bfr$ is a multiple of $(p)$, and so $\bfr$ is a multiple of $(p)/\gcd( \af,(p))$. Therefore for there to be $p^3$ choices of $\bfr\Mod{p}$, $\af$ must be a multiple of $(p)/\pf$ for some degree one prime ideal $\pf$ above $p$. Since there are $O(1)$ degree one prime ideals $\pf$ above $p$ and there are $O(p)$ different multiples of $(p)/\pf$ we see that there are $O(p)$ possible vectors $\aa$ such that $M_\aa$ has rank 1.

Since the rank is unchanged by replacing $\aa$ with $\lambda\aa$ for any non-zero scalar $\lambda$, we see all such $\aa$ are scalar multiples of one of $O(1)$ choices of vector $\aa^{(0)}$.

Call such a vector $\aa^{(0)}$ `normal' if the constraints $(\aa^{(0)}\diamond \cc_2)_4\equiv\vv\cdot(\aa^{(0)}\diamond \cc_2)\equiv 0\Mod{p}$ are non-trivial on $\cc_2\Mod{p}$, and call $\aa^{(0)}$ `exceptional' if the constraints are trivial on $\cc_2\Mod{p}$. We see that if $\aa^{(0)}$ is normal, then there are $O(p^3)$ choices of $\cc_2\Mod{p}$ and so $O(p^4)$ choices of $(\cc_2,\aa)\Mod{p}$ with $\aa$ a multiple of $\aa^{(0)}$.

We now prove that when $p$ is large enough,  there are no exceptional $\aa^{(0)}$.

If $(\aa^{(0)}\diamond \cc)_4\equiv 0\Mod{p}$ $\forall \cc$, then this equation holds in particular for all $\cc$ in  $\{(1,0,0,0), (0,1,0,0), (0,0,1,0), (0,0,0,1)\} $.
Writing $\aa^{(0)}=(a_1^{(0)}, a_2^{(0)},a_3^{(0)},a_4^{(0)})$ and $\nu_i\nu_j=\sum_{k=1}^4 \lambda_{ijk}\nu_k$, we get
$$\sum_{i=1}^4\lambda_{ij4}a_i^{(0)}\equiv 0\Mod p\qquad j=1,2,3,4.$$
This implies that $p|\det (\lambda_{ij4})_{1\le i,j\le 4}$ which is not possible for $p$ large enough if this determinant is non zero.

But this determinant can't be zero, otherwise, there would be $\mu_1,\mu_2,\mu_3,\mu_4$ such that
\[
\mu_1 \begin{pmatrix} \lambda_{114}\\ \lambda_{214} \\ \lambda_{314}\\ \lambda_{414}\end{pmatrix}
+\mu_2 \begin{pmatrix} \lambda_{124}\\ \lambda_{224} \\ \lambda_{324}\\ \lambda_{424}\end{pmatrix}
+\mu_3 \begin{pmatrix} \lambda_{134}\\ \lambda_{234} \\ \lambda_{334}\\ \lambda_{434}\end{pmatrix}
+\mu_4 \begin{pmatrix} \lambda_{144}\\ \lambda_{244} \\ \lambda_{344}\\ \lambda_{444}\end{pmatrix}=0,
\]
and then the matrix of the multiplication by $\mu_1\nu_1+\mu_2\nu_2+\mu_3\nu_3+\mu_4\nu_4$ wouldn't be invertible. Thus $c_p=0$ for all $p\in [P_1,P_2]$.

Thus, we have that
\[
\frac{1}{p^2}\widetilde{S}_1(\cc_1,\cc_2)=\frac{1}{p}\sum_{\aa^{(0)}\text{ normal}}\1_{\substack{(\aa^{(0)}\diamond \cc_1)_4\equiv\vv\cdot(\aa^{(0)}\diamond \cc_1)\equiv 0\Mod{p}\\ (\aa^{(0)}\diamond \cc_2)_4\equiv\vv\cdot(\aa^{(0)}\diamond \cc_2)\equiv 0\Mod{p}}}+  O\Bigl(\frac{1}{p^2}\Bigr).
\]
However, we have
\[
\sum_{\cc_1,\cc_2\Mod{p}}\frac{1}{p}\sum_{\aa^{(0)}\text{ normal}}\1_{\substack{(\aa^{(0)}\diamond \cc_1)_4\equiv\vv\cdot(\aa^{(0)}\diamond \cc_1)\equiv 0\Mod{p}\\ (\aa^{(0)}\diamond \cc_2)_4\equiv\vv\cdot(\aa^{(0)}\diamond \cc_2)\equiv 0\Mod{p}}}\ll p^5.
\]
This gives the result.
\end{proof}
We're now in a position to simply our sum.
\begin{lmm}\label{lmm:T11}
\[
T_{11}':=\sum_{\substack{p\in [P_1,P_2]\\ p\equiv 1\Mod{D_f}}}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m} \\ \wedge(\bb_1,\bb_2)\ne 0\\ p\nmid N(\bb_1) N(\bb_2) D_{\bb_1,\bb_2}}}\frac{g_{\bb_1}g_{\bb_2}}{f_{\bb_1,\bb_2,p,p}\det(\Lambda_{\bb_1,\bb_2})}.
\]
Then we have
\[
T_{11}'\ll \frac{B^6}{P_1}+P_2^7 B^{17/3}.
\]
\end{lmm}
\begin{proof}
Firstly, by splitting $\bb_1,\bb_2$ into residue classes $\Mod{p}$, we have that
\begin{align*}
&=\sum_{\substack{p\in [P_1,P_2]\\ p\equiv 1\Mod{D_f}}}\sum_{\substack{\cc_1,\cc_2\Mod{p}\\ \cc_1\not\propto\cc_2\\ N(\cc_1)N(\cc_2)\ne 0\Mod{p} }}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m} \\ \wedge(\bb_1,\bb_2)\ne 0\\ \bb_1\equiv \cc_1\Mod{p}\\ \bb_2\equiv \cc_2\Mod{p} }}\frac{g_{\bb_1}g_{\bb_2}}{f_{\bb_1,\bb_2,p,p}\det(\Lambda_{\bb_1,\bb_2})}.
\end{align*}
Using our expression \eqref{eq:ftoS}, we see that this is given by
\begin{align*}
&\sum_{\substack{p\in [P_1,P_2]\\ p\equiv 1\Mod{D_f}}}\sum_{\substack{\cc_1,\cc_2\Mod{p}\\ \cc_1\not\propto\cc_2\\ N(\cc_1)N(\cc_2)\ne 0\Mod{p} }}\sum_{j=0}^4 \frac{\widetilde{S}_j(\cc_1,\cc_2)}{p^2}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m} \\ \wedge(\bb_1,\bb_2)\ne 0\\ \bb_1\equiv \cc_1\Mod{p}\\ \bb_2\equiv \cc_2\Mod{p} }}\frac{g_{\bb_1}g_{\bb_2}}{\det(\Lambda_{\bb_1,\bb_2})}.
\end{align*}
Using Lemma \ref{lmm:S1} we get
\begin{align}
T_{11}'&=O\Bigl(\sum_{\substack{p\in [P_1,P_2]\\ p\equiv 1\Mod{D_f}}}\sum_{\substack{\cc_1,\cc_2\Mod{p}\\ \cc_1\not\propto\cc_2\Mod{p}\\ N(\cc_1)N(\cc_2)\ne 0\Mod{p} }}\frac{T(\cc_1,\cc_2)}{p^2}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m} \\ \wedge(\bb_1,\bb_2)\ne 0\\ \bb_1\equiv \cc_1\Mod{p}\\ \bb_2\equiv \cc_2\Mod{p} }}\frac{|g_{\bb_1}g_{\bb_2}|}{\det(\Lambda_{\bb_1,\bb_2})}\Bigr),\label{eq:SeparatedExpression}
\end{align}
\[
\]
By Lemma \ref{lmm:BasicSum}, we have that
\[
\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m} \\ \wedge(\bb_1,\bb_2)\ne 0\\ \bb_1\equiv \cc_1\Mod{p}\\ \bb_2\equiv \cc_2\Mod{p} }}\frac{|g_{\bb_1}g_{\bb_2}|}{\det(\Lambda_{\bb_1,\bb_2})}\ll \frac{B^6}{p^8}+B^{17/3}.
\]
Lemmas \ref{lmm:S0}, \ref{lmm:S1}, \ref{lmm:S23}, \ref{lmm:S4t} show that
\[
\sum_{\cc_1,\cc_2\Mod{p}}\frac{T(\cc_1,\cc_2)}{p^2}\ll p^6.
\]
Thus we see that the  term $T_{11}'$
\eqref{eq:SeparatedExpression} is
\begin{align*}
\ll \sum_{\substack{p\in [P_1,P_2]\\ p\equiv 1\Mod{D_f}}}p^6\Bigl(\frac{B^6}{p^8}+B^{17/3}\Bigr)\ll \frac{B^6}{P_1}+B^{17/3}P_2^7.
\end{align*}
This ends the proof of Lemma \ref{lmm:T11}. \end{proof}

Putting everything in this section together, we are left to show that
\[
T_{12}\ll \eta_2^5 B^6.
\]
\subsection{The case $p_1\ne p_2$}
In this section we bound the sum $T_{12}$ given by \eqref{eq:T12Def}.
\begin{lmm}\label{lmm:T12}
We have
\[
T_{12}\ll |S_{sep}|+\frac{B^6}{P_1}+P_2^7 B^{17/3},
\]
where, $S_{sep}$ is given by
\[
\]
\end{lmm}
\begin{proof}
We wish to reintroduce terms with $p_1\nmid N(\bb_1)$ and $p_2\nmid N(\bb_2)$ so that the inner sum is independent of $p_1,p_2$. There are $O(p_1^3)$ choices of $\cc_1\Mod{p_1}$ such that $p_1|N(\cc_1)$. Thus, by Lemma \ref{lmm:BasicSum}, we see that the terms with $p_1|N(\bb_1)$ contribute a total
\begin{align*}
&\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\frac{1}{p_1 p_2}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m} \\ \wedge(\bb_1,\bb_2)\ne 0\\ p_1| N(\bb_1)}}\frac{|g_{\bb_1}g_{\bb_2}|D_{\bb_1,\bb_2}}{\wedge(\bb_1,\bb_2)}\\
&\ll \sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\frac{1}{p_1 p_2}\sum_{\substack{\cc_1,\cc_2\Mod{p_1}\\ p_1|N(\cc_1)}}\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \wedge(\bb_1,\bb_2)\ne 0\\ \bb_1\equiv \cc_1\Mod{p_1} \\ \bb_2\equiv \cc_2\Mod{p_2} )}}\frac{|g_{\bb_1}g_{\bb_2}|D_{\bb_1,\bb_2}}{\wedge(\bb_1,\bb_2)}\\
&\ll \sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\frac{1}{p_1 p_2}p_1^7\Bigl(\frac{B^6}{p_1^8}+B^{17/3}\Bigr)\\
&\ll \frac{B^6}{P_1}+P_2^7 B^{17/3}.
\end{align*}
Similarly, we see that terms $p_2|N(\bb_2)$ contribute a total $O(B^6/P_1+P_2^7 B^{17/3})$. Thus we find that
\begin{align*}
T_{12}&=\Bigl(\sum_{\substack{p_1,p_2\in [P_1,P_2]\\ p_1\equiv p_2\equiv 1\Mod{D_f}}}\frac{1}{p_1 p_2}\Bigr)\Bigl(\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\bb_2\in \ZZ^4\cap\Cc_2\\  \bb_1\equiv \bb_2\equiv \bb_0\Mod{m} \\ \wedge(\bb_1,\bb_2)\ne 0 }}\frac{g_{\bb_1}g_{\bb_2}D_{\bb_1,\bb_2}}{\wedge(\bb_1,\bb_2)}\Bigr)\\
&\qquad\qquad+O\Bigl(\frac{B^6}{P_1}+P_2^7 B^{17/3}\Bigr).
\end{align*}
Noting that the sum over $p_1,p_2$ is $O(1)$, this gives the result.
\end{proof}
Thus it remains to bound $S_{sep}$.
\subsection{Reduction to small residue classes and small boxes}
We first show that the contribution to $S_{sep}$ from terms with $D_{\bb_1,\bb_2}>(\log{B})^K$ or $\wedge(\bb_1,\bb_2)\le B^2/(\log{B})^K$ is negligible.
\begin{lmm}
\begin{align*}
\sum_{\substack{\bb_1\in \ZZ^4\cap \Cc_1,\,\bb_2\in\ZZ^4\cap\Cc_2\\ \wedge(\bb_1,\bb_2)>0 \\ \max(B^2/\wedge(\bb_1,\bb_2),D_{\bb_1,\bb_2})>(\log{B})^K}}\frac{|g_{\bb_1}g_{\bb_2}|}{\det(\Lambda_{\bb_1,\bb_2})}\ll_K\frac{B^6}{(\log{B})^K}.
\end{align*}
\end{lmm}
\begin{proof}
This is similar to the proof of Lemma \ref{lmm:BasicSum}. Indeed, the argument in the proof of Lemma \ref{lmm:BasicSum} shows that the contribution from terms with $\wedge(\bb_1,\bb_2)\ll B^{4/3}$ is $O(B^{17/3})$, and the contribution from terms with $\wedge(\bb_1,\bb_2)\sim B^2/C$ (for $C=2^j\ll B^{2/3}$) and $D_{\bb_1,\bb_2}=d$ is
\[
\ll \frac{dC}{B^2}\Bigl(B+\frac{B^4}{C^3d^3}\Bigr).
\]
Thus we see that the total contribution is
\[
\ll B^{17/3}+\sum_{C=2^j\ll B}\sum_{\substack{d\le B\\ \max(d,C)>(\log{B})^K}}\frac{dC}{B^2}\Bigl(B+\frac{B^4}{C^3d^3}\Bigr)\ll_K \frac{B^6}{(\log{B})^K}.\qedhere
\]
\end{proof}
Thus we just need to consider $D_{\bb_1,\bb_2}\le (\log{x})^K$ and $\wedge(\bb_1,\bb_2)\ge B^2/(\log{x})^K$.
\begin{lmm}\label{lmm:Ssep}
Imagine that for every cube $\Cc\subseteq[1,B]^4$, every and any $\cc\Mod{d}$ and every $K>0$ we have
\[
\sum_{\substack{\bb\in \ZZ^4\cap \Cc \\ \bb\equiv \cc\Mod{d}}}g_\bb \ll_K\frac{B^4}{(\log{B})^{10K}}.
\]
Then for every choice of $K>0$ we have that
\[
S_{sep}\ll_K \frac{B^6}{(\log{B})^K}
\]
\end{lmm}
\begin{proof}
Since $\wedge(\bb_1,\bb_2)$ is continuous in $\bb_1,\bb_2$ we see that if a pair of cubes $\Cc_1',\Cc_2'$ of side length $B/(\log{x})^{2K}$ contains a point with $\wedge(\bb_1,\bb_2)\ge B^2/(\log{x})^K$, then in fact for all $\bb_1'\in\Cc'_1$ and $\bb_2\in\Cc'_2$ we have $\wedge(\bb_1',\bb_2')=\wedge(\bb_1,\bb_2)(1+O(\log{x})^{-K})$. Thus we may replace $\wedge(\bb_1,\bb_2)$ with
\[
\wedge(\Cc_1',\Cc_2'):=\sup_{\xx\in\Cc_1',\yy\in\Cc_2'}\wedge(\xx,\yy)
\]
at the cost of an error term of size $B^6/(\log{x})^K$. Thus we have
\[
S_{sep}\ll \frac{B^6}{(\log{x})^K}+\frac{(\log{x})^{9K}}{B^2} \sum_{d\le (\log{x})^K}d\sup_{\Cc_1',\Cc_2'}\sum_{\substack{\bb_1\in\ZZ^4\cap\Cc_1',\,\bb_2\in\ZZ^4\cap\Cc'_2\\ D_{\bb_1,\bb_2}=d}}g_{\bb_1}g_{\bb_2}.
\]
Now we wish to simplify the condition $D_{\bb_1,\bb_2}=d$ to a congruence condition, which will finally allow us to separate the variables $\bb_1,\bb_2$. By Moebius inversion we have
\begin{align*}
\mathbf{1}_{D_{\bb_1,\bb_2}=d}&=\sum_{e|D_{\bb_1,\bb_2}/d}\mu(e)\\
&=\sum_{e\le (\log{x})^{30K} }\mu(e)\mathbf{1}_{\bb_1\propto\bb_2\Mod{de}}+O((\log{x})^{30K}\mathbf{1}_{D_{\bb_1,\bb_2}\ge (\log{x})^{30K}}).
\end{align*}
By Lemma \ref{lmm:Cylinder}, the contribution of the second term to $S_{sep}$ is $O(B^4/(\log{x})^{K})$. Thus we see that
\begin{align}
S_{sep}\ll \frac{B^6}{(\log{x})^A}+(\log{x})^{50K}\sup_{\substack{\Cc_1',\Cc_2'\\ de\ll (\log{B})^{31K}}}| S_{sep}'|
\end{align}
\begin{align*}
S_{sep}'&:=\sum_{\bb,\lambda_1,\lambda_2\Mod{de}}\Biggl(\sum_{\substack{\bb_1\in\ZZ^4\cap\Cc_1',\\ \bb_1\equiv \lambda_1\bb\Mod{de}\\ \bb_1\equiv \bb_0\Mod{m}}}g_{\bb_1}\Biggr)\Biggl(\sum_{\substack{\bb_2\in\ZZ^4\cap\Cc_2',\\ \bb_2\equiv \lambda_2\bb\Mod{de}\\ \bb_2\equiv \bb_0\Mod{m}}}g_{\bb_2}\Biggr).
\end{align*}
By assumption of the lemma, we have that
\[
\sum_{\substack{\bb_1\in\ZZ^4\cap\Cc_1',\\ \bb_1\equiv \lambda_1\bb\Mod{de}\\ \bb_1\equiv \bb_0\Mod{m}}}g_{\bb_1}\ll_K \frac{B^4}{(\log{x})^{100K}}.
\]
Substituting this in then gives the final bound.
\end{proof}
Thus we see that it is sufficient to obtain a suitable bound for $g_{\bb}$ on average over hypercubes in residue classes.
\subsection{Localised bound and Proof of Proposition \ref{prpstn:T1}}

To finish our proof we need to show that we have a suitable estimate for $g_{\bb}=\1_{\Rc}(\bb)-\widetilde{\1}_{\Rc}(\bb)$ over $\bb$ restricted to small boxes and arithmetic progressions.  We don't require estimates arithmetic progressions to moduli larger than $(\log{X})^{O(1)}$, and there are no issues caused by a possible Siegel zero.

\begin{prpstn}\label{prpstn:Local}
For every $K>0$ and every polytope $\mathcal{R}$ under consideration, we have
\[
\sum_{\substack{\bb\in \ZZ^4\cap \Cc \\ \bb\equiv \cc\Mod{d}}}\Bigl(\mathbf{1}_{\mathcal{R}}(\bb)-\widetilde{\mathbf{1}}_{\mathcal{R}}(\bb)\Bigr) \ll_K\frac{B^4}{(\log{B})^{10K}}.
\]
\end{prpstn}
\begin{proof}
This is the equivalent of \cite[Proposition 9.7]{May15b}, and the proof works in exactly the same manner for our situation. Therefore we only highlight a couple of main details.

First we estimate the contribution from $\1_{\Rc}(\bb)$. Since $\bb$ is in a small cube, no two elements can generate the same ideal, and so we can write the sum as a sum of principal ideals. We can use Hecke Grossencharacters to detect the congruence conditions and the restriction of $\bb$ to the cube $\mathcal{C}$. The Prime Number Theorem for Grossencharacters then allows one to suitably estimate the resulting sums over $\1_{\Rc}(\bb)$, giving an explicit main term and an error term which is $O_K(B^4/(\log{B})^{10K})$. This is essentially the same argument as \cite[Lemmas 9.1-9.4]{May15b}.

The contribution from $\widetilde{\1}_{\Rc}(\bb)$ can be estimated by swapping the order of summation in the sieve sum and using the fact that $\bb\in\mathbb{Z}\cap\mathcal{C}$ are equidistributed in suitable aritmetic progressions as in \cite[Lemmas 9.5 and 9.6]{May15b}. This gives a main term and a error term $O_K(B^4/(\log{B})^{10K})$.

The main term contributions from $\1_{\Rc}(\bb)$ and $\widetilde{\1}_{\Rc}(\bb)$ are the same apart from opposite signs and so cancel, giving the result.
\end{proof}
Finally, we are able to complete our proof of Proposition \ref{prpstn:T1}.
\begin{proof}[Proof of Proposition \ref{prpstn:T1}]
Putting together the equations \eqref{eq:T1}, \eqref{eq:Tc} and the argument of Section \ref{sec:Cosmetic},  we find that provided $B<X^{3/4-\epsilon}/P_2^{3/2}$ (from \eqref{eq:BSize}) we have
\begin{align*}
T_1(\cR)&=\sum_{\cC\in Cl_K}\sum_{\substack{{\a_0,\b_0 \Mod{m'}}\\ {N(\gc )(\a_0\diamond \b_0)_i\equiv (\v_0)_i\Mod {m'}}}} T_3(\cR)+O(X^{3+\epsilon}/P_1),
\end{align*}
where $T_3$ is given by \eqref{eq:T3Def}.

Putting together \eqref{eq:T3}, \eqref{eq:T4}, \eqref{eq:T6} and Lemmas \ref{lmm:T5} \ref{lmm:T7}, \ref{lmm:T8}, \ref{lmm:T11}, \ref{lmm:T12}, \ref{lmm:Ssep}, and Proposition \ref{prpstn:Local} then gives
\begin{align*}
T_3(\cR)^2&\ll_K \eta_2^{-5}A^4\Bigl(A^3B^3+AB^7P_2^2+A^2B^{17/3}P_2^7+\frac{A^2B^6}{(\log{X})^K}\Bigr).
\end{align*}
Since $|\cAI(X_0)|\asymp A^3B^3$, this gives the result provided
\begin{align*}
\end{align*}
(Here we used that the second inequality implies \eqref{eq:BSize}.) After taking $\epsilon$ suitably small, we see that the first condition is implied by the first inequality of \eqref{eq:th5}, whereas the final two inequalities are implied by the assumption $\tau'\le \min(4-2\theta_1'-\cdots-2\theta'_{\ell'},\theta_1+\dots+\theta_{\ell'}-1)/100$. This gives Proposition \ref{prpstn:T1}.
\end{proof}

This completes the proof of Proposition \ref{prpstn:T1}, and hence Theorem \ref{DistriNorm} and Theorem \ref{cP}.

\bibliographystyle{plain}
\begin{thebibliography}{10}

[1]
R.~de~la Bret\`eche.
\newblock Plus grand facteur premier de valeurs de polyn\^omes aux entiers.
\newblock {\em Acta Arith.}, 169:221--250, 2015.

[2]
R.~de~la Bret\`eche and S.~Drappeau.
\newblock Niveau de répartition des polynômes quadratiques et crible majorant
pour les entiers friables.
\newblock {\em J. Eur. Math. Soc.}, 22(5):1577--1624, 2020.

[3]
\newblock Galois groups of cubics and quartics (not in characteristic $2$).
\newblock {\em

[4]
\newblock Le probl\`eme de {T}ch\'ebychev pour le douzi\`eme polyn\^ome
\newblock {\em Proc. London Math. Soc.}, 111(1):1--62, 2015.

[5]
J.-M. Deshouillers and H.~Iwaniec.
\newblock On the greatest prime factor of $n^2+1$.
\newblock {\em Ann. Inst. Fourier (Grenoble)}, 32(4):1--11, 1982.

[6]
\newblock On the greatest prime factor of $\prod_{k=1}^x f(k)$.
\newblock {\em J. London Math. Soc.}, 27:379--384, 1952.

[7]
D.~R. Heath-Brown.
\newblock Diophantine approximation with square-free numbers.
\newblock {\em Math. Z.}, 187(3):335--344, 1984.

[8]
D.~R. Heath-Brown.
\newblock The largest prime factor of $x^3+2$.
\newblock {\em Proc. London Math. Soc.}, 82(3):554--596, 2001.

[9]
\newblock On the greatest prime factor of a quadratic polynomial.
\newblock {\em Acta Math.}, 281-299:21--50, 1967.

[10]
A.~J. Irving.
\newblock The largest prime factor of $x^3+2$.
\newblock {\em Acta Arith.}, 171(1):67--80, 2015.

[11]
\newblock A new form of the error term in the linear sieve.
\newblock {\em Acta Arith.}, 37:307--320, 1980.

[12]
\newblock Rosser's sieve.
\newblock {\em Acta Arith.}, 36:171--202, 1980.

[13]
C.~U. Jensen, A.~Ledet, and N.~Yui.
\newblock {\em Generic Polynomials: Constructive Aspects of the Inverse Galois
Problem}, volume~45.
\newblock Math. Sci. Res. Inst. Publ., Cambridge Univ. Press, Cambridge, 2002.

[14]
\newblock Primes represented by incompletes norm forms.
\newblock {\em Forum of Mathematics, Pi}, 8(3):1--128, 2020.

[15]
\newblock On the largest prime factor of $n^2 +1$.
\newblock {\em https://arxiv.org/abs/1908.08816v3.pdf}, 2021.

[16]
\newblock {\em Elementary and analytic theory of algebraic numbers}, volume
Third Edition.
\newblock Springer, 712 pp., 2004.

[17]
A.~Schinzel and W.~Sierpi\'nski.
\newblock Sur certaines hypoth\`eses concernant les nombres premiers.
\newblock {\em Acta Arithmetica}, 4(3):185--208, 1958.

[18]
\newblock Sur une question d'{E}rd{\H{o}}s et {S}chinzel. {II}.
\newblock {\em Invent. Math.}, 99:215--224, 1990.

[19]
\newblock {\em Lehrbuch der Algebra}, volume~2.
\newblock Vieweg and Sohn, 592 pp., 1899.

\end{thebibliography}

\vskip 2cm

\noindent Cécile Dartyge, Institut \'Elie Cartan, Université de Lorraine, BP 70239, 54506 Vand\oe uvre-lès-Nancy Cedex, France

\noindent<EMAIL_ADDRESS>
\hfill\\

\noindent James Maynard, Mathematical Institute, Woodstock Road, Oxford OX2 6GG, UK

\noindent<EMAIL_ADDRESS>\end{document}

\include{C4D4V10.bib}