#include #include #include #include #include #include #define N 20using namespace std;int n,a[N];bool vis[N];int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar();} while(ch>='0'&&ch<='9') {x=x*10+ch-'0'; ch=getchar();} return x*f;}int pd(int x){ for(int i=2;i<=sqrt(x);i++) if(!(x%i)) return 0; return 1; }int print(){ for(int i=1;i<=n;i++) printf("%d ",a[i]); printf("\n");}int dfs(int x){ for(int i=2;i<=n;i++) if(!vis[i]&&pd(a[x-1]+i)) { vis[i]=1; a[x]=i; if(x==n&&pd(a[1]+a[n])) print(); else dfs(x+1); vis[i]=0; }}int main(){ n=read(); a[1]=1; dfs(2); return 0;}