A square of is subdivided into 9 small squares of . It is desired to distribute the nine digits in each small square of , a number in each small square. Find the number of different distributions that can be formed in such a way that the difference of the digits in cells that share a side in common is less than or equal to three. Two distributions are distinct even if they differ by rotation and/or reflection.
CL-MO 2019
Chile national mathematics olympiad 2019.