Problem

Source: Kyiv City MO 2021 Round 1, Problem 8.3

Tags: permutations, Magic squares, combinatorics



The $1 \times 1$ cells located around the perimeter of a $3 \times 3$ square are filled with the numbers $1, 2, \ldots, 8$ so that the sums along each of the four sides are equal. In the upper left corner cell is the number $8$, and in the upper left is the number $6$ (see the figure below). How many different ways to fill the remaining cells are there under these conditions? Proposed by Mariia Rozhkova