#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<vector>
#include<string>
#include<stdio.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N=4050;
const int MAX=1000000100;
const int mod=100000000;
const int MOD1=1000000007;
const int MOD2=1000000009;
const double EPS=0.00000001;
typedef long long ll;
const ll MOD=998244353;
const int INF=1000000010;
const double pi=acos(-1.0);
typedef double db;
typedef unsigned long long ull;
bool q[N],bo[N];
int tot,u[N],v[40*N],cap[40*N],flow[40*N],pre[40*N];
void add(int a,int b,int c,int f) {
v[tot]=b;cap[tot]=c;flow[tot]=f;pre[tot]=u[a];u[a]=tot++;
}
int d[N],dis[N],head[N];
bool bfs(int a,int b) {
int i,l=1,r=1;
memset(q,0,sizeof(q));
d[1]=a;q[a]=1;dis[a]=0;
for (;l<=r;l++)
for (i=u[d[l]];i!=-1;i=pre[i])
if (!q[v[i]]&&cap[i]>flow[i]) q[v[i]]=1,d[++r]=v[i],dis[v[i]]=dis[d[l]]+1;
return q[b];
}
int dfs(int a,int b,int en) {
if (a==en||b==0) return b;
int ret=0,f;
for (int& i=u[a];i!=-1;i=pre[i])
if (dis[v[i]]==dis[a]+1&&(f=dfs(v[i],min(b,cap[i]-flow[i]),en))>0) {
flow[i]+=f;flow[i^1]-=f;
b-=f;ret+=f;
if (b==0) break ;
}
return ret;
}
int pd(int a) {
int i,j,sum=0;
tot=0;memset(u,-1,sizeof(u));
for (i=1;i<=a;i++) {
add(0,i,1,0),add(i,0,0,0);
add(i+a,2*a+1,1,0);add(2*a+1,i+a,0,0);
}
for (i=1;i<=a;i++)
for (j=i+1;j<=a;j++)
if (bo[i+j]) add(i,j+a,1,0),add(j+a,i,0,0);
for (i=0;i<=2*a+1;i++) head[i]=u[i];
while (bfs(0,2*a+1)) {
sum+=dfs(0,INF,2*a+1);
for (i=0;i<=2*a+1;i++) u[i]=head[i];
}
return a-sum;
}
void deal(int a) {
memset(bo,0,sizeof(bo));
for (int i=1;i*i<=a;i++) bo[i*i]=1;
}
void out(int a,int b) {
int i,bo=0;q[a]=1;
for (i=u[a];i!=-1;i=pre[i])
if (v[i]!=0&&v[i]!=2*b+1&&flow[i]&&!q[v[i]-b]) {
bo=1;printf("%d ", a);
out(v[i]-b,b);
}
if (!bo) printf("%d\n", a);
}
int main()
{
int i,n,l=1,r=1800,mid=(l+r)>>1;
scanf("%d", &n);
deal(3700);
if (n<=0) { printf("0\n");return 0; }
while (l+1<r)
if (pd(mid)<=n) { l=mid;mid=(l+r)>>1; }
else { r=mid;mid=(l+r)>>1; }
printf("%d\n", l);pd(l);
memset(q,0,sizeof(q));
for (i=1;i<=l;i++)
if (!q[i]) out(i,l);
return 0;
}