https://www.luogu.com.cn/problem/P2089
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;
typedef vector<long long> VI;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define pb(i) push_back(i)
#define int long long
#define INF 0x3f3f3f3f
#define oz 998244353
#define endl '\n'
#define N 200010
const int mod = 1e9 + 7;
int p[N], si[N];
int find(int x) {
if (x != p[x]) p[x] = find(p[x]);
return p[x];
}
//size[find(b)] += size[find(a)];
//p[find(a)] = find(b);
int ans[60000][20];
int n, res;
int arr[15];
void dfs(int x, int y) { // x枚举到哪一位 y调料数总和
if (y > n)return; //
if (y + 3 * (10 - x + 1) < n)return ;
if (x > 10 && y == n) {
res ++;
rep(i, 1, 10) {
ans[res][i] = arr[i];
}
return ;
}
for (int i = 1; i <= 3; i++) {
arr[x] = i;
dfs(x + 1, y + i);
arr[x] = 0;
}
}
void solve() {
cin >> n;
if (n < 10 || n > 30) {
cout << 0 << endl;
return ;
}
dfs(1, 0);
cout << res << endl;
rep(i, 1, res) {
rep(j, 1, 10) {
cout << ans[i][j] << " ";
}
cout << endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
solve();
return 0;
}