We divided a rectangle into two rows and six columns. We wanted to write the numbers 1 to 12 in the resulting 12 cells so that the sum of the numbers in each column is 13, and the sum of the numbers in each row is 39. In how many ways is this possible?
In one column, 1 can only be with 12, 2 with 11, ..., and 6 with 7. Thus, the tables that satisfy the first condition are those that can be derived from the following table by swapping columns and swapping two numbers within columns:

| 1 | 2 | 3 | 4 | 5 | 6 |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 12 | 11 | 10 | 9 | 8 | 7 |

In this table, the sum of the numbers in the upper row is 21, and the sum of the numbers in the lower row is 57. To make the sum 39-39, we need to swap numbers in some columns. With each swap, the sum of the upper row increases by 11, 9, 7, 5, 3, or 1. The sum of the upper row needs to increase by $39-21=18$, so we need to form 18 as the sum of some of these 6 numbers. Since 18 is an even number, it can only be obtained as the sum of an even number of odd numbers. The sum of 0 or 6 terms is not suitable, as it would give 0 or 36. The sum of two terms can only be $11+7$, so one of the valid tables is:

| 12 | 2 | 10 | 4 | 5 | 6 |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 1 | 11 | 3 | 9 | 8 | 7 |

For the sum of four terms, the sum of the two missing numbers must be $11+9+7+5+3+1-18=18$, so the only four-term sum is $9+5+3+1$ from the missing terms of the previously obtained two-term sum. The corresponding table is:

| 1 | 11 | 3 | 9 | 8 | 7 |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 12 | 2 | 10 | 4 | 5 | 6 |

We have no more options for swapping numbers within the columns, so all possible tables can be derived from one of these two tables by swapping columns. Since we can get 6 columns swapped in $6 \cdot 5 \cdot 4 \cdot 3 \cdot 2 \cdot 1=720$ different ways, the filling can be done in $720+720=1440$ ways.