12. If the three sides of a right triangle are pairwise coprime positive integers, then such a right triangle is called a primitive right triangle.
(1) Find the number of primitive right triangles in which the area is exactly $n$ times the perimeter, and denote this number as $a_{n}$;
(2) Find $\max _{1 \leqslant n \leqslant 2023} a_{n}$, and list all primitive right triangles whose area is exactly 2023 times the perimeter.