// Problem: P2089 烤鸡
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P2089
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// User: Pannnn
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<vector<int>> &res, vector<int> &tmp, int sum, int n, int pos) {
if (pos >= 10) {
if (sum == n) {
res.push_back(tmp);
}
return;
}
for (int i = 1; i <= 3; ++i) {
tmp[pos] = i;
dfs(res, tmp, sum + i, n, pos + 1);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
vector<vector<int>> res;
int n;
cin >> n;
vector<int> tmp(10);
dfs(res, tmp, 0, n, 0);
cout << res.size() << endl;
for (int i = 0; i < res.size(); ++i) {
for (int j = 0; j < res[i].size(); ++j) {
cout << res[i][j] << " ";
}
cout << endl;
}
return 0;
}