12. For two sets $A, B$, define
$$
\begin{aligned}
A \Delta B= & \{x \mid x \in A, \text { and } x \notin B\} \cup \\
& \{x \mid x \in B, \text { and } x \notin A\} .
\end{aligned}
$$

Let $n > 1$ be an integer, and $A_{1}, A_{2}, \cdots, A_{2 n}$ be all the subsets of
$$
S=\{1,2, \cdots, n\}
$$

$M$ is a $2^{n} \times 2^{n}$ matrix. For any $i, j \in\left\{1,2, \cdots, 2^{n}\right\}$, the sum of all elements in the set $A_{i} \Delta A_{j}$ (with the convention that the sum of elements in the empty set is 0) is filled in the position of the $i$-th row and $j$-th column of the matrix $M$. Find the sum of all numbers in the matrix $M$.
12. When calculating the sum of numbers in table $M$, to calculate how many times each $x \in S$ is counted, it is only necessary to count the number of all ordered pairs $(i, j)(i, j \in\{1, 2, \cdots, 2^{n}\})$ that satisfy $x \in A_{i} \Delta A_{j}$.

For an element $x \in A_{i} \Delta A_{j}$, there are only two scenarios, i.e., $x \in A_{i}, x \notin A_{j}$ or $x \in A_{j}, x \notin A_{i}$. For any element $y \neq x$, its membership relationship with sets $A_{i}$ and $A_{j}$ has $2^{2}=4$ possible cases. Therefore, the number of ordered pairs $(i, j)$ that satisfy $x \in A_{i} \Delta A_{j}$ is $2 \times 4^{n-1}=2^{2 n-1}$. Thus, each $x \in S$ is counted $2^{2 n-1}$ times in the summation.
Hence, the sum of all numbers in the table is
$$
\begin{array}{l}
2^{2 n-1} \sum_{x \in S} x=2^{2 n-1}(1+2+\cdots+n) \\
=2^{2 n-2} n(n+1) .
\end{array}
$$