#include<iostream>
#include<cmath>
using namespace std;
int n ;
long sum = 0;
int *x;
bool place (int k)
{
for(int j=1; j<k; j++)
if(abs(k-j) == abs(x[j]-x[k]) || (x[j] == x[k]))
return false;
return true;
}
void backtrack(int t)
{
if(t > n){
sum++;
}
else for(int i=1; i<=n; i++){
x[t] = i;
if(place(t)) backtrack(t+1);
}
}
long nQueen(int nn)
{
n = nn;
sum=0;
x = new int[n+1];
for(int i=0; i<=n; i++)
x[i]=0;
backtrack(1);
return sum;
}
int main()
{
cout<<"请输入N皇后N的个数"<<endl;
while(cin>>n){
if(n<=0){
cout<<"no solute!";
}else
{
if(nQueen(n) == 0)
cout<<"no solute!<<endl";
else cout<<sum;
}
}
return 0;
}