A square matrix is a spiral123 matrix when all three conditions hold.

For one $n$ there are many $n \times n$ spiral123 matrices, so the output section fixes one of them. Given $n$, print that matrix.
The first line contains one integer $n$.
Print $n$ lines. Line $i$ holds row $i$ of the matrix $M(n)$ defined below, written as $n$ numbers separated by single spaces. Rows and columns are numbered from $0$.
For $5 \le n \le 10$, $M(n)$ is the matrix below. Each block writes one entry as one digit and one matrix row as one line.
$M(5)$
12003
30120
20031
03210
01302
$M(6)$
123000
301020
000231
010302
032100
200013
$M(7)$
1230000
3010020
0000231
0103002
0021300
0302100
2000013
$M(8)$
12300000
30100020
00200031
00010302
00032100
01003200
03021000
20000013
$M(9)$
000000123
200000031
120003000
003100002
012030000
031002000
000321000
300000210
000210300
$M(10)$
0012300000
0003120000
0020000031
0000000312
0000231000
0000002103
2000013000
0130000200
1300000020
3201000000
For $n \ge 11$, build $M(n)$ from $M(n-6)$. Let $r = (0, 1, 2, n-3, n-2, n-1)$. Start with an $n \times n$ matrix of zeros. For every $i$ and $j$ from $0$ to $5$, copy the entry of $M(6)$ in row $i$, column $j$ into row $r_i$, column $r_j$. Then, for every $i$ and $j$ from $0$ to $n-7$, copy the entry of $M(n-6)$ in row $i$, column $j$ into row $i+3$, column $j+3$. Every other entry stays $0$.
$M(n)$ is a spiral123 matrix for every $n$ in the input range.