# include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # include # define F first # define S second # define mp make_pair # define pb push_back # define ll long long # define ld long double # define pii pair # define ull unsigned long long const int Sz = 1048575; const int MX = 1073741822; const ll MXLL = 1844674407370955161ll; using namespace std; inline void rcin () { ios_base::sync_with_stdio(0); cin.tie(NULL); } int dist[26][26], n; int plusx[] = {+1, +1, -1, -1}; int plusy[] = {+1, -1, +1, -1}; bool in_range (int x, int y) { if (x >= 1 && y >= 1 && x <= n && y <= n) return 1; else return 0; } int knight (int a, int b) { memset (dist, -1, sizeof dist); queue q; q.push (mp (1, 1)); dist[1][1] = 0; while (!q.empty()) { int x = q.front().F, y = q.front().S; for (int i = 0;i < 4;i ++) { int tox = plusx[i] * a + x; int toy = plusy[i] * b + y; if (in_range (tox, toy) && dist[tox][toy] == -1) { dist[tox][toy] = dist[x][y] + 1; q.push (mp (tox, toy)); } } swap (a, b); for (int i = 0;i < 4;i ++) { int tox = plusx[i] * a + x; int toy = plusy[i] * b + y; if (in_range (tox, toy) && dist[tox][toy] == -1) { dist[tox][toy] = dist[x][y] + 1; q.push (mp (tox, toy)); } } swap (a, b); q.pop(); } return dist[n][n]; } int main() { rcin (); cin >> n; for (int i = 1;i <= n-1;i ++) for (int j = 1;j <= n-1;j ++) cout << knight (i, j) << " \n"[j == n-1]; return 0; }