#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <list>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define N 1000006
using namespace std;
int n,ans;
bool g[14][14];
int lz[14];
bool check(int h,int l) {
for (int i = 1; i <= n; ++i) {
if (i!=h) if (g[i][l]) return false;
if (i!=l) if (g[h][i]) return false;
if (h+i<=n&&l+i<=n) if (g[h+i][l+i]) return false;
if (h-i<=n&&l-i<=n) if (g[h-i][l-i]) return false;
if (h+i<=n&&l-i<=n) if (g[h+i][l-i]) return false;
if (h-i<=n&&l+i<=n) if (g[h-i][l+i]) return false;
}
return true;
}
void dfs(int h) {
if (h==n+1) {
ans++;
if (ans<=3) {
for (int i = 1; i < n; ++i) {
printf("%d ",lz[i]);
}
printf("%d\n",lz[n]);
}
return ;
}
for (int i = 1; i <= n; ++i) {
if (check(h,i)) {
lz[h]=i;
g[h][i]= true;
dfs(h+1);
g[h][i]= false;
}
}
return;
}
int main () {
scanf("%d",&n);
dfs(1);
cout<<ans;
return 0;
}