Prime Factorization of the Least Common Multiple

Prove that
\[
\operatorname{lcm}(n,m)
= p_1^{\max(a_1,b_1)}p_2^{\max(a_2,b_2)}\cdots p_r^{\max(a_r,b_r)},
\]
given that $n$ and $m$ are positive integers with
\[
\begin{aligned}
n &= p_1^{a_1}p_2^{a_2}\cdots p_r^{a_r},\\
m &= p_1^{b_1}p_2^{b_2}\cdots p_r^{b_r},
\end{aligned}
\]
where $p_1,\ldots,p_r$ are distinct primes given by the Fundamental Theorem of Arithmetic and $a_i,b_i$ are nonnegative integers.

Solutions