#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
#include <functional>
#include <set>
#include <map>
#include <string>
using namespace std;
int ans;
int n;
int q[20];
int res[100001][20];
void dfs(int u,int tot)
{
if (u > 10)
{
if (tot == n)
{
for (int i = 1; i <= 10; i++) res[ans][i] = q[i];
ans++;
}
return;
}
for (int i = 1; i <= 3; i++)
{
if (tot + i > n) break;
q[u] = i;
dfs(u + 1, tot + i);
}
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n;
if (n < 10 || n > 30)
{
cout << 0;
return 0;
}
dfs(1, 0);
cout << ans << endl;
for (int i = 0; i < ans; i++)
{
for (int j = 1; j <= 10; j++)
{
cout << res[i][j] << ' ';
}
puts("");
}
return 0;
}