#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) using namespace std; const int N=10; int n; char q[N][N]; bool col[N],dg[2*N],udg[2*N]; void dfs(int u){ if(u==n){ rep(i,0,n) puts(q[i]); puts(""); return; } rep(i,0,n){ if(!col[i]&&!dg[u+i]&&!udg[n-u+i]){ q[u][i]='Q'; col[i]=dg[u+i]=udg[n-u+i]=true; dfs(u+1); col[i]=dg[u+i]=udg[n-u+i]=false; q[u][i]='.'; } } } int main(){ cin>>n; rep(i,0,n) rep(j,0,n) q[i][j]='.'; dfs(0); return 0; }