## Task B-1.3.

To the vertices of the square $A B C D$, Matko assigned different natural numbers less than 16 in such a way that the arithmetic mean of the numbers assigned to any three chosen vertices of the square is an integer. In how many different ways could Matko have numbered the vertices of the square?
## Solution.

Let the numbers assigned to the vertices of the square be denoted by $a, b, c,$ and $d$, where $a, b, c, d \in \{1, 2, \ldots, 15\}$. According to the conditions of the problem, the sums $a+b+c, a+b+d, a+c+d, b+c+d$ must be divisible by 3. We will consider all cases in which this can be achieved.

First case: all four chosen numbers are divisible by 3.

Then the four numbers are chosen from the set $\{3, 6, 9, 12, 15\}$. From 5 different numbers, we can choose 4 different numbers in 5 ways (since we are choosing one that we will not take).

Second case: all four chosen numbers give a remainder of 1 when divided by 3.

Then the four numbers are chosen from the set $\{1, 4, 7, 10, 13\}$. Again, they can be chosen in 5 ways.

Third case: all four chosen numbers give a remainder of 2 when divided by 3.

Then the four numbers are chosen from the set $\{2, 5, 8, 11, 14\}$. Again, they can be chosen in 5 ways.

Fourth case: in each triplet whose sum we consider, one of the chosen numbers gives a remainder of 0 when divided by 3, another gives a remainder of 1, and the third gives a remainder of 2.

We will show that this cannot be achieved for all choices of three numbers from the set $\{a, b, c, d\}$. Without loss of generality, consider a selection in which the number $a$ is divisible by 3, the number $b$ gives a remainder of 1 when divided by 3, and the number $c$ gives a remainder of 2.

If the number $d$ is divisible by 3, the sums $a+b+d$ and $a+c+d$ will not be divisible by 3. If the number $d$ gives a remainder of 1 when divided by 3, the sums $a+b+d$ and $b+c+d$ are not divisible by 3. If the number $d$ gives a remainder of 2 when divided by 3, the sums $a+c+d$ and $b+c+d$ are not divisible by 3.

Therefore, the remainders when divided by 3 must be the same for all 4 numbers $a, b, c,$ and $d$, so the total number of ways to choose the numbers for labeling the vertices of the square is $5+5+5=15$. For each of these choices, the four numbers can be arranged in $4 \cdot 3 \cdot 2 \cdot 1=24$ ways, so the total number of different ways to label the vertices of the square under the given conditions is $15 \cdot 24=360$.