Solution (source code)

= Solution

Using $a_i=b_i+nu_i$ with <integers> $u_i$,
$$
\begin{aligned}
a_1a_2-b_1b_2
&=(b_1+nu_1)(b_2+nu_2)-b_1b_2\\
&=n(b_1u_2+b_2u_1+nu_1u_2).
\end{aligned}
$$
The quantity in parentheses is an <integer>, so the <divisibility> criterion for <modular arithmetic> gives
$$
\boxed{a_1a_2\equiv b_1b_2\pmod n.}
$$