#include<bits/stdc++.h>
using namespace std;
int n,a[17],vis[17];
void print()
{
for(int i=1;i<=n;i++)
cout<<a[i]<<' ';
cout<<"\n";
}
bool is_pri(int x)
{
for(int i=2;i*i<=x;i++)
if(x%i==0) return 0;
return 1;
}
void dfs(int cur)
{
if(cur>n&&is_pri(a[1]+a[n])) print();
else
for(int i=2;i<=n;i++)
if(!vis[i]&&is_pri(a[cur-1]+i))
{
a[cur]=i,vis[i]=1;
dfs(cur+1);
vis[i]=0;
}
}
int main()
{
int t=0;
while(cin>>n)
{
memset(a,0,sizeof(a));
memset(vis,0,sizeof(vis));
a[1]=vis[1]=1;
cout<<"Case "<<++t<<":"<<"\n";
dfs(2);
cout<<"\n";
}
return 0;
}
确定核心代码没问题,但是格式不对qwq,救救蒟蒻吧……