/*
八皇后问题其实和数字排列问题差不多只需要弄懂一下问题
1.怎么判断不在同一条直线
这个很简单判断这个数字有没有被用过就知道
2.怎么判断不在同一条斜线
3.怎么判断不在同一条反斜线
*/
import java.util.*;
public class Main{
static int N = 10;
static int n;
static char[][] path = new char[N][N];
static boolean[] stat = new boolean[N2];
static boolean[] eg = new boolean[N2];
static boolean[] ueg = new boolean[N*2];
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
for(int i = 0;i < n;i){
for(int j = 0;j < n;j){
path[i][j] = ‘.’;
}
}
dfs(0);
}
private static void dfs(int u){
if(u >= n){
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
System.out.print(path[i][j]);
}
System.out.println();
}
System.out.println();
return;
}
for(int i = 0; i < n;i++){
if(!stat[i]&&!eg[u + i]&&!ueg[n - u + i]){
path[u][i] = 'Q';
stat[i] = eg[u + i] = ueg[n - u + i] = true;
dfs(u + 1);
stat[i] = eg[u + i] = ueg[n - u + i] = false;
path[u][i] = '.';
}
}
}
}