#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> mas(n + 2, vector<int>(n + 2));
	rep(q, n + 2) {
		rep(w, n + 2) {
			mas[q][w] = 31;
		}
	}
	for (int q = 1; q <= n; ++q) {
		for (int w = 1; w <= n; ++w) {
			mas[q][w] = 0;
		}
	}
	
	vector<int> dx = { 1,0,-1,0 };
	vector<int> dy = { 0,1,0,-1 };
	int a = 1;
	int i = 1, j = 1;
	int p = 0;
	while (a <= n * n) {
		mas[i][j] = a;
		a++;
		if ((dx[p] != 0 && mas[i + dx[p]][j] != 0) || (dy[p] != 0 && mas[i][j + dy[p]] != 0)) {
			p++;
		}
		if (p == 4) {
			p = 0;
		}
		i += dx[p];
		j += dy[p];
	}
	for (int q = 1; q <= n; ++q) {
		for (int w = 1; w <= n; ++w) {
			cout << setfill('0') << right << setw(3) << mas[w][q] << ' ';
		}
		cout << endl;
	}
	return 0;
}