//用dfs深度优先搜索方法做
include[HTML_REMOVED]
using namespace std;
const int N=10;
char p[N][N];
int n;
bool a[N],xa[2N],xb[2N];
void dfs(int u)
{
if(u==n)
{
for(int i=0;i<n;i)
cout <<p[i]<<endl;
cout <<endl;
}
for(int i=0;i<n;i)
{
if(a[i]||xa[i+u]||xb[n+u-i]) continue;
a[i]=xa[i+u]=xb[n+u-i]=true;
p[u][i] = 'Q';
dfs(u+1);
a[i]=xa[i+u]=xb[n+u-i]=false;
p[u][i] = '.';
}
}
int main()
{
cin >>n;
for(int i=0;i<n;i)
for(int j=0;j<n;j)
p[i][j] =’.’;
dfs(0);
return 0;
}