#include using namespace std; int main () { int N; cin >> N; int M = N * 2 - 1; cout << M << endl; vector ans; for (int i = M; i >= N; i --) { int a = i; if ((M - i) % 2) { a = M - i; } for (int j = 0; j < a; j ++) { ans.push_back(a); } if (a < M) { for (int j = 0; j < M - a; j ++) { ans.push_back(M - a); } } } for (int i = 0; i < M; i ++) { for (int j = 0; j < N; j ++) { cout << ans[i + j * M] << (j < N - 1 ? " " : ""); } cout << endl; } }