import java.util.Scanner;
public class P2089烤鸡 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int count = 0; //计算符合要求的方法有多少
String[] s = new String[10000]; //用来放答案,有的方法可能大于8000;
//10个循环,每一成代表一种配料;
for(int q=1;q<=3;q++) { //每种配料可以放1到3克
for(int w=1;w<=3;w++) {
for(int e=1;e<=3;e++) {
for(int r=1;r<=3;r++) {
for(int t=1;t<=3;t++) {
for(int y=1;y<=3;y++) {
for(int u=1;u<=3;u++) {
for(int i=1;i<=3;i++) {
for(int o=1;o<=3;o++) {
for(int p=1;p<=3;p++) {
if(q+w+e+r+t+y+u+i+o+p == n) { //判断所有配料质量之和是否等于n
s[count] = q+" "+w+" "+e+" "+r+" "+t+" "+y+" "+u+" "+i+" "+o+" "+p;
count++;
}
}
}
}
}
}
}
}
}
}
}
if(count == 0) { //如果没有符合要求的方法,就只要在第一行输出一个0
System.out.println(count);
}else { //否则输出答案
System.out.println(count);
for(int i=0;i<count;i++) {
System.out.println(s[i]);
}
}
}
}