#include<bits/stdc++.h>
using namespace std;
int ans=0;
int main()
{
int n;
cin>>n;
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
for(int a=1;j<=3;j++)
{
for(int b=1;j<=3;j++)
{
for(int c=1;j<=3;j++)
{
for(int d=1;j<=3;j++)
{
for(int e=1;j<=3;j++)
{
for(int f=1;j<=3;j++)
{
for(int k=1;j<=3;j++)
{
for(int l=1;j<=3;j++)
{
if(i+j+a+b+c+d+e+f+k+l==n)
{
ans++;
}
}
}
}
}
}
}
}
}
}
}
cout<<ans<<endl;
if(ans==0)
{
return 0;
}
for(int i=1;i<=3;i++)
{
for(int j=1;j<=3;j++)
{
for(int a=1;j<=3;j++)
{
for(int b=1;j<=3;j++)
{
for(int c=1;j<=3;j++)
{
for(int d=1;j<=3;j++)
{
for(int e=1;j<=3;j++)
{
for(int f=1;j<=3;j++)
{
for(int k=1;j<=3;j++)
{
for(int l=1;j<=3;j++)
{
if(i+j+a+b+c+d+e+f+k+l==n)
{
cout<<i<<" ";
cout<<j<<" ";
cout<<a<<" ";
cout<<b<<" ";
cout<<c<<" ";
cout<<d<<" ";
cout<<e<<" ";
cout<<f<<" ";
cout<<k<<" ";
cout<<l<<" ";
cout<<endl;
}
}
}
}
}
}
}
}
}
}
}
return 0;
}