6. Let $a_{i} \in\{1,2, \cdots, 9\}(1 \leqslant i \leqslant n)$, and $a_{1}>a_{2}>\cdots>a_{n}$. If $A$ is a $p$-digit number, $B$ is a $q$-digit number $(p<q, p+q=n)$, and the union of the sets of digits of $A$ and $B$ is exactly $\left\{a_{1}, a_{2}, \cdots, a_{n}\right\}$, then the maximum value of the product $A B$ is
6. $a_{2} a_{3} \cdots a_{2 p-1} a_{2 p+1} a_{2 p+2} \cdots a_{n} \cdot a_{1} a_{4} a_{6} \cdots a_{2 p}$.

First, arrange the first digits of the two numbers, one of which must be $a_{1}$ and the other $a_{2}$.

Next, arrange the second digits (if any) of the two numbers, one of which must be $a_{3}$ and the other $a_{4}$. This is because, regardless of whether there are digits following them, in the "product $AB$", the position of their product is higher than that of the product of the digits following them.
Compare $\overline{a_{1} a_{3}} \cdot \overline{a_{2} a_{4}}$ with $\overline{a_{1} a_{4}} \cdot \overline{a_{2} a_{3}}$.
Let $a_{3}-a_{4}=r$. If we replace $\overline{a_{1} a_{3}} \cdot \overline{a_{2} a_{4}}$ with $\overline{a_{1} a_{3}} \cdot \overline{a_{2} a_{3}}$, it increases by $r$ times $\overline{a_{1} a_{3}}$.

Further replacing it with $\overline{a_{1} a_{4}} \cdot \overline{a_{2} a_{3}}$, it decreases by $r$ times $\overline{a_{2} a_{3}}$.

Thus, $\overline{a_{1} a_{3}} \cdot \overline{a_{2} a_{4}}$ to $\overline{a_{1} a_{4}} \cdot \overline{a_{2} a_{3}}$ increases by $r$ times $\left(\overline{a_{1} a_{3}}-\overline{a_{2} a_{3}}\right)>0$.
Therefore, $\overline{a_{1} a_{3}} \cdot \overline{a_{2} a_{4}}<\overline{a_{1} a_{4}} \cdot \overline{a_{2} a_{3}}$.
From the above discussion, we know that the two highest and second-highest numbers should be placed in the first positions, and then the second digits of the two numbers should be arranged. The largest (or the one with more digits) of the remaining numbers should be placed in the second position of the number with the smaller first digit, and the second-largest in the other number's second position. Next, arrange the third digits, placing the largest (or the one with more digits) of the remaining numbers in the third position of the number with the smaller first digit, and so on, until all digits are arranged. Therefore, the largest product is
$$
\overline{a_{2} a_{3} \cdots a_{2 p-1} a_{2 p+1} a_{2 p+2} \cdots a_{n}} \cdot \overline{a_{1} a_{4} a_{6} \cdots a_{2 p}} \text {. }
$$