#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;

int MAX = 2e5;
int a[10], n;

void backtrack(int n) {
    if (n == 0) {
        cout << ::n << '\n';

        for (int i = 1; i <= ::n; i++) {
            if (i > 1) cout << ' ';
            cout << a[i];
        }

        cout << '\n';

        MAX--;
        if (MAX <= 0) exit(0);

        return;
    }

    for (int x = 1; x <= 6; x++) {
        a[n] = x;
        backtrack(n - 1);
        a[n] = 0;
    }
}

int power(int base, int exp) {
    if (exp == 0) return 1;
    return base * power(base, exp - 1);
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;

    MAX /= n;
    MAX = min(MAX, power(6, n));

    cout << MAX << '\n';
    backtrack(n);

    return 0;

}