3. In how many ways can a $3 \times 3$ table be filled with elements of the set $\{10,3,2018\}$ such that the sum of the numbers in each row, each column, and both diagonals is divisible by 3?
3. Three given numbers, when divided by three, give remainders 0, 1, and 2 (each remainder appears exactly once). Therefore, for the sum of any three of them to be divisible by 3, they must either all be equal or all different. Thus, in each row, each column, and on both diagonals, there must be either three equal numbers or three different numbers.

Consider the first row of this table. First, consider the case when it is filled with three different numbers. Now, consider the central cell. Regardless of which number is there, the rest of the table can be filled in a unique way (indeed, for each cell in the third row, we have a unique choice, as it completes a column or diagonal with two already written numbers, so if these two numbers are equal, the third number must also be equal to them, and if these two numbers are different, the third number must be different from both; after filling the entire third row, similarly, we see that the remaining two cells in the middle row also have a unique choice). Since the first row can be filled in $3 \cdot 2=6$ ways, and the central cell can then be filled in 3 ways, the total number of fillings in this case is 18.

Now, let the first row of the table be filled with three equal numbers. Similarly as before, we determine that, regardless of how the central cell is filled, the rest of the table can be filled in a unique way. Since the first row can be filled in 3 ways, and the central cell can then be filled in 3 ways, the total number of fillings in this case is 9.

Therefore, the total number of fillings is 27.