#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;

#define int64 long long
#define uint64 unsigned long long
#define pb push_back
#define mp make_pair
#define M_PI 3.1415926535898



int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << 1 << endl;
		for (int i = 1; i < n; ++i) {
			for (int j = 0; j < n - i; ++j) {
				cout << "1 ";
			}
			cout << endl;
		}
	}
	else {
		cout << 2 << endl;
		for (int i = 1; i < n; ++i) {
			for (int j = 0; j < n - i; ++j) {
				cout << j % 2 + 1<< ' ';
			}
			cout << endl;
		}
	}
	return 0;
}