usingSystem;usingSystem.Collections.Generic;namespace N皇后
{classProgram{publicstaticList<List<string>>Qdeen(int n){List<List<string>> res =newList<List<string>>();List<string> map =newList<string>();int[,] attack =newint[n, n];Track(attack, map,res);return res;}staticvoidsetAttack(int x,int y,int[,] attack,List<string> map){string temp ="";int n = attack.GetLength(0);for(int i =0; i < n; i++){
temp += i == y ?'Q':'T';}
map.Add(temp);int[] dx =newint[]{-1,0,1,1,1,0,-1,-1};int[] dy =newint[]{1,1,1,0,-1,-1,-1,0};for(int i =1; i < n; i++){for(int j =0; j < dx.Length; j++){if(x + dx[j]* i>=0&& x + dx[j]* i<n&& y + dy[j]* i>=0&&y + dy[j]* i<n)
attack[x + dx[j]* i, y + dy[j]* i]=1;}}}staticvoidTrack(int[,] attack,List<string> map,List<List<string>> res){int n = attack.GetLength(0);int index = map.Count;if(index == n){
res.Add(newList<string>(map));return;}for(int i =0; i < n; i++){if(attack[index, i]!=0)continue;int[,] temp =(int[,])attack.Clone();setAttack(index, i, attack,map);Track(attack, map,res);
attack = temp;
map.RemoveAt(index);}}staticvoidMain(string[] args){int n =int.Parse(Console.ReadLine());List<List<string>> res =Qdeen(n);foreach(var item in res){foreach(var sub in item){
Console.WriteLine(sub);}
Console.WriteLine("------------------");}
Console.WriteLine(res.Count);}}}