#include #include using namespace std; using namespace atcoder; //const long nPrime = 1000000007; //const long nPrime = 998244353; typedef long long ll; int main() { long n; cin >> n; vector> vviAns(n,vector(2*n-1,-1)); for(long i = 0; i < 2*n-1; i++){ vviAns[0][i] = 2*n-1; } long iTmp = 0; for(long i = 1; i <= n-1; i++){ for(long j = 0; j < i; j++){ long k = (iTmp+j)%(2*n-1); vviAns[i][k] = i; } for(long j = i; j < 2*n-1; j++){ long k = (iTmp+j)%(2*n-1); vviAns[i][k] = 2*n-1-i; } if(i <= 7){ iTmp += (i+2)/2; } else { iTmp += 2; } iTmp %= (2*n-1); } cout << 2*n-1 << endl; for(long i = 0; i < 2*n-1; i++){ for(long j = 0; j < n; j++){ cout << vviAns[j][i] << " "; } cout << endl; } return 0; }