using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var len = 2 * n - 1; var ans = new int[len][]; for (var i = 0; i < ans.Length; ++i) ans[i] = new int[n]; for (var i = 0; i < n; ++i) { if (i + 1 == n) { for (var j = 0; j < len; ++j) ans[j][i] = len; } else { for (var j = 0; j <= i; ++j) ans[(i + j) % len][i] = i + 1; for (var j = i + 1; j < len; ++j) ans[(i + j) % len][i] = len - i - 1; } } WriteLine(len); WriteLine(string.Join("\n", ans.Select(ai => string.Join(" ", ai)))); } }