Since at least one $a_i$ is not a unit and we find that $\mathfrak m$ is not an associated prime of $A$. Moreover, for any $A \subset B$ as in the statement $\mathfrak m$ is not an associated prime of $B$ and $\mathfrak m_j$ is not an associate prime of $B_j$. Keeping this in mind will help check the arguments below. \medskip\noindent First, we claim that it suffices to prove the lemma for $r = 2$. We will argue this by induction on $r$; we suggest the reader skip the proof. Suppose we are given $A \subset B$ and $\pi_j$ in $B_j = B_{\mathfrak m_j}$ and factorizations $a_i = u_{i, j} \pi_j^{e_{i, j}}$ for $i = 1, \ldots, r - 1$ in $B_j$ with $u_{i, j} \in B_j$ units and $e_{i, j} \geq 0$. Then by the case $r = 2$ for $\pi_j$ and $a_r$ in $B_j$ we can find extensions $B_j \subset C_j$ and for every maximal ideal $\mathfrak m_{j, k}$ of $C_j$ a nonzerodivisor $\pi_{j, k} \in C_{j, k} = (C_j)_{\mathfrak m_{j, k}}$ and factorizations $$ \pi_j = v_{j, k} \pi_{j, k}^{f_{j, k}} \quad\text{and}\quad a_r = w_{j, k} \pi_{j, k}^{g_{j, k}} $$ as in the lemma. There exists a unique finite extension $B \subset C$ with $C/B$ annihilated by a power of $\mathfrak m$ such that $C_j \cong C_{\mathfrak m_j}$ for all $j$, see Lemma \ref{lemma-glue-at-max}. The maximal ideals of $C$ correspond $1$-to-$1$ to the maximal ideals $\mathfrak m_{j, k}$ in the localizations and in these localizations we have $$ a_i = u_{i, j} \pi_j^{e_{i, j}} = u_{i, j} v_{j, k}^{e_{i, j}} \pi_{j, k}^{e_{i, j}f_{j, k}} $$ for $i \leq r - 1$. Since $a_r$ factors correctly too the proof of the induction step is complete. \medskip\noindent Proof of the case $r = 2$. We will use induction on $$ \ell = \min(\text{length}_A(A/a_1A),\ \text{length}_A(A/a_2A)). $$ If $\ell = 0$, then either $a_1$ or $a_2$ is a unit and the lemma holds with $A = B$. Thus we may and do assume $\ell > 0$. \medskip\noindent Suppose we have a finite extension of rings $A \subset A'$ such that $A'/A$ is annihilated by a power of $\mathfrak m$ and such that $\mathfrak m$ is not an associated prime of $A'$. Let $\mathfrak m_1, \ldots, \mathfrak m_r \subset A'$ be the maximal ideals and set $A'_i = A'_{\mathfrak m_i}$. If we can solve the problem for $a_1, a_2$ in each $A'_i$, then we can apply Lemma \ref{lemma-glue-at-max} to produce a solution for $a_1, a_2$ in $A$. Choose $x \in \{a_1, a_2\}$ such that $\ell = \text{length}_A(A/xA)$. By Lemma \ref{lemma-compare-periodic-lengths}  and (\ref{equation-multiplicity-coker-ker}) we have $\text{length}_A(A/xA) = \text{length}_A(A'/xA')$. On the other hand, we have $$ \text{length}_A(A'/xA') = \sum [\kappa(\mathfrak m_i) : \kappa(\mathfrak m)] \text{length}_{A'_i}(A'_i/xA'_i) $$ by Algebra, Lemma \ref{algebra-lemma-pushdown-module}. Since $x \in \mathfrak m$ we see that each term on the right hand side is positive. We conclude that the induction hypothesis applies to $a_1, a_2$ in each $A'_i$ if $r > 1$ or if $r = 1$ and $[\kappa(\mathfrak m_1) : \kappa(\mathfrak m)] > 1$. We conclude that we may assume each $A'$ as above is local with the same residue field as $A$. \medskip\noindent Applying the discussion of the previous paragraph, we may replace $A$ by the ring constructed in Lemma \ref{lemma-Noetherian-domain-dim-1-two-elements} for $a_1, a_2 \in A$. Then since $A$ is local we find, after possibly switching $a_1$ and $a_2$, that $a_2 \in (a_1)$. Write $a_2 = a_1^m c$ with $m > 0$ maximal. In fact, by Lemma \ref{lemma-not-infinitely-divisible} we may assume $m$ is maximal even after replacing $A$ by any finite extension $A \subset A'$ as in the previous paragraph. If $c$ is a unit, then we are done. If not, then we replace $A$ by the ring constructed in Lemma \ref{lemma-Noetherian-domain-dim-1-two-elements} for $a_1, c \in A$. Then either (1) $c = a_1 c'$ or (2) $a_1 = c a'_1$. The first case cannot happen since it would give $a_2 = a_1^{m + 1} c'$ contradicting the maximality of $m$. In the second case we get $a_1 = c a'_1$ and $a_2 = c^{m + 1} (a'_1)^m$. Then it suffices to prove the lemma for $A$ and $c, a'_1$. If $a'_1$ is a unit we're done and if not, then $\text{length}_A(A/cA) < \ell$ because $cA$ is a strictly bigger ideal than $a_1A$. Thus we win by induction hypothesis.