//打表记录1到40的素数表
#include<iostream>
#include<math.h>
using namespace std;
const int maxn = 40;
int n;
int used[maxn];
int s[maxn];
bool v[maxn];
void prime(){
memset(v, 1, sizeof(v));
for(int j = 2; j < 40; j++){
for(int i = 2; i <= sqrt(double(j)); i++){
if(j % i == 0){
v[j] = 0;
break;
}
}
}
}
void dfs(int x){
if(x == n && v[1 + s[x - 1]] ){ //第一个和最后一个也要满足两数相加为素数
for(int i = 0; i < x; i++){
if(i == 0)
printf("%d", s[i]);
else
printf(" %d", s[i]);
}
printf("
");
}
else {
for(int i = 2; i <= n; i++){
if(used[i] || !v[s[x - 1] + i])
continue;
used[i] = 1;
s[x] = i;
dfs(x + 1);
used[i] = 0;
}
}
}
int main(){
int c = 1;
prime();
while(cin>>n){
s[0] = 1;
cout<<"Case "<<c++<<":"<<endl;
memset(used, 0, sizeof(used));
dfs(1);
cout<<endl;
}
}