#include <bits/stdc++.h>using namespace std;int n,tot=0,a[15];void dfs(int step){ if(step>n) { tot++; if(tot<4) { for(int i=1; i<=n; i++) { cout<<a[i]<<' '; } cout<<endl; } return; } for(int i=1;i<=n;i++){ a[step]=i;//选列 int x=step,y=i,flag=1; for(int j=1;j<step;j++){ if(j+a[j]==x+y||x-y==j-a[j]||y==a[j]){//根据数学关系排除 flag=0; break; } } if(flag) dfs(step+1);//符合选入 } return;}int main(){ cin>>n; dfs(1); cout<<tot; return 0;}