CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #926 #928 →

#927. Build a spiral matrix

You get n. Print the n×n matrix with the numbers 1 to n² placed in a clockwise spiral that starts at the top-left. ### Input One integer n (1 ≤ n ≤ 8). ### Output n lines.

Examples

Input
3
Output
1 2 3
8 9 4
7 6 5
Input
5
Output
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!