#include <iostream>
using namespace std;
int con[8] = {-1, -1, -1, 1, 1, -1, 1, 1};
const int N = 15;
int c[N][N];
int ans[N];
int n;
int fun(int, int, int);
int res;
int main()
{
for (int i=0; i<N; i++)
{
ans[i] = -1;
}
while ((cin >> n) && n)
{
res = 0;
for (int i=0; i<n; i++)
{
for (int j=0; j<n; j++)
{
c[i][j] = 0;
}
}
if (ans[n] == -1)
{
ans[n] = fun(0, 0, n);
}
cout << ans[n] << endl;
}
return 0;
}
int fun(int i, int j, int chenum)
{
if (!chenum)
{
res++;
return res;
}
if ((i<n) && (j==n))
{
j = 0;
i++;
}
if (i == n)
{
return res;
}
c[i][j] = 1;
int p;
for (p=0; p<n; p++)
{
if (p == i)
{
continue;
}
if (1 == c[p][j])
{
break;
}
}
int q;
for (q=0; q<n; q++)
{
if (q == j)
{
continue;
}
if (1 == c[i][q])
{
break;
}
}
int m, y, flag = 0;
for (y=0; y<8; y+=2)
{
m = 1;
while ((con[y]*m+i>=0) && (con[y]*m+i<n) && (con[y+1]*m+j>=0) && (con[y+1]*m+j<n))
{
if (c[con[y]*m+i][con[y+1]*m+j] == 1)
{
flag = 1;
break;
}
m++;
}
if (flag)
{
break;
}
}
if ((q == n) && (p == n) && (y == 8))
{
res = fun(i+1, 0, chenum-1);
c[i][j] = 0;
}
else
{
c[i][j] = 0;
}
c[i][j] = 0;
if ((j == n-1) && (i+chenum > n)) //各位看官请把后面这个n改成n-1
{
return res;
}
res = fun(i, j+1, chenum);
return res;
}