Let $R$ be a commutative ring where $m_1,m_2,\ldots,m_r$ and $n_1,n_2,\ldots,n_s$ are maximal ideals such that $m_1m_2\ldots m_r=n_1n_2\ldots n_s$ and $m_i \neq m_j$, $n_i \neq n_j$ if $i \neq j$. Prove that $r=s$ and there the exists $\sigma \in S_r$ such that $m_i=n_{\sigma(i)}$ for all $i$.
So far I have proved that $\lbrace m_i \rbrace$ are pairwise comaximal, i.e., $m_i+m_j=R$ and $m_1m_2 \ldots m_r=m_1 \cap m_2 \cap \ldots \cap m_r$. But I have no idea how to proceed to prove that $r=s$. Any hints or ideas?
Without a loss of generality, assume that $r \leqslant s$.
Since every maximal ideal is a prime ideal, note that $$m_1m_2\ldots m_r=n_1n_2\ldots n_s\subset n_i,i=1,\ldots ,s$$ then there exist a $\sigma(i)\in \{ 1,\dots,r\}$ such that $m_{\sigma(i)}\subset n_1$. But since $m_{\sigma(i)}$ is maximal, and $n_1$ is proper, $m_{\sigma(i)}=n_i$.
Note that $\sigma(i)\not=\sigma(j)$ for $i\not=j$ since $n_i\not=n_j$. It follows that $r=s$ and $\sigma$ is a permutation in $S_r$.