#include<stdio.h>
int count ;
int queen ;
void Answers( int row, int ml, int mr)
{
if(row != queen)
{
int pos = queen & ~(row|ml|mr);
while(pos)
{
int p = pos & -pos;
pos -= p;
Answers( row|p, (ml|p)>>1, (mr|p)<<1);
}
}
else
count++;
}
int main( )
{
int n,i;
while(scanf("%d",&n) == 1)
{
if( n == 0 )
{
break;
}
count =0;
queen =1;
queen=(queen<<n)-1;
Answers(0,0,0);
printf("%d\n",count);
}
return 0;
}