description: A chess tournament will be held soon, where n chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.
  
  Each of the players has their own expectations about the tournament, they can be one of two types:
  
    1. a player wants not to lose any game (i. e. finish the tournament with zero losses); 
    2. a player wants to win at least one game. 
  
  
  
  You have to determine if there exists an outcome for all the matches such that all the players meet their expectations. If there are several possible outcomes, print any of them. If there are none, report that it's impossible.
  
  Input
  
  The first line contains a single integer t (1 ≤ t ≤ 200) — the number of test cases.
  
  The first line of each test case contains one integer n (2 ≤ n ≤ 50) — the number of chess players.
  
  The second line contains the string s (|s| = n; s_i ∈ \{1, 2\}). If s_i = 1, then the i-th player has expectations of the first type, otherwise of the second type.
  
  Output
  
  For each test case, print the answer in the following format:
  
  In the first line, print NO if it is impossible to meet the expectations of all players.
  
  Otherwise, print YES, and the matrix of size n × n in the next n lines.
  
  The matrix element in the i-th row and j-th column should be equal to:
  
    * +, if the i-th player won in a game against the j-th player; 
    * -, if the i-th player lost in a game against the j-th player; 
    * =, if the i-th and j-th players' game resulted in a draw; 
    * X, if i = j. 
  
  Example
  
  Input
  
  
  3
  3
  111
  2
  21
  4
  2122
  
  
  Output
  
  
  YES
  X==
  =X=
  ==X
  NO
  YES
  X--+
  +X++
  +-X-
  --+X
solution: /**
   * @author -- Sourav Joshi
   */
  
  //			               _,--"^^"-.,_
  //			         _.-"~^`~-.    .-~`^~"-._
  //			     ,="`"-._     .----.     _.-"`"=,
  //			    ;_       "-. (0 )( 0) .-"       _;
  //			   .' `~"=,_    '.\ \/ /.'    _,="~` `.
  //			   ;_       "-. _.-)  (-._ .-"       _;
  //			   : ^~"-.,___.'  (    )  `.___,.-"~^ ;
  //			   :        _:     `--'     :_        :
  //			    '._,-~"` :':          :': `"~-,_.'
  //			       '.,_.-`.            .'`-._,.'
  //			          :__.-`-.______.-'`-.__;
  //			                 //    \\
  //			               (((~    ~)))
  
  import java.util.*;
  
  
  import static java.lang.Math.max;
  import static java.lang.Math.min;
  import static java.lang.Math.abs;
  import static java.lang.Math.ceil;
  import static java.lang.Math.max;
  import static java.lang.Math.pow;
  import java.io.*;
  
  public class Solution {
  
  	static FastScanner s = new FastScanner();
  	static FastWriter out = new FastWriter();
  	final static int mod = 1000000000 + 7;
  	final static int INT_MAX = Integer.MAX_VALUE;
  	final static int INT_MIN = Integer.MIN_VALUE;
  	final static long LONG_MAX = Long.MAX_VALUE;
  	final static long LONG_MIN = Long.MIN_VALUE;
  	final static double DOUBLE_MAX = Double.MAX_VALUE;
  	final static double DOUBLE_MIN = Double.MIN_VALUE;
  	final static float FLOAT_MAX = Float.MAX_VALUE;
  	final static float FLOAT_MIN = Float.MIN_VALUE;
  
  
  	static class Pair<T,R>{
  		T first;
  		R Second;
  	}
  
  	static class compare implements Comparator<Pair<Integer, Integer>>{
  
  		@Override
  		public int compare(Solution.Pair<Integer, Integer> o1, Solution.Pair<Integer, Integer> o2) {
  			if(o1.first == o2.first) {
  				return o1.Second - o2.Second;
  			}else {
  				return o1.first - o2.first;
  			}
  		}
  
  	}
  
  	static class FastScanner{
  		BufferedReader br;
  		StringTokenizer st;
  
  		public FastScanner() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
  
  		String next(){
  			while (st == null || !st.hasMoreElements()){
  				try{
  					st = new StringTokenizer(br.readLine());
  				}catch (IOException  e){
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
  		int nextInt(){
  			return Integer.parseInt(next());
  		}
  		long nextLong(){
  			return Long.parseLong(next());
  		}
  
  		double nextDouble(){
  			return Double.parseDouble(next());
  		}
  		String nextLine(){
  			String str = "";
  			try{
  				str = br.readLine();
  			}
  			catch (IOException e){
  				e.printStackTrace();
  			}
  			return str;
  		}
  	}
  
  	static class FastWriter{
  		private final BufferedWriter bw;
  
  		public FastWriter() {
  			this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
  		}
  
  		public void print(Object object) throws IOException{
  			bw.append(""+ object);
  		}
  
  		public void println(Object object) throws IOException{
  			print(object);
  			bw.append("\n");
  		}
  
  		public void close() throws IOException{
  			bw.close();
  		}
  	}
  	
  	public static boolean check(String str, int s, int e) {
  		int a = 0;
  		int b = 0;
  		for(int i = s; i <= e; i++) {
  			char ch = str.charAt(i);
  			if(ch == 'a') a++;
  			if(ch == 'b') b++;
  		}
  		if(a == b) return true;
  		else return false;
  	}
  	
  	public static void fill(char arr[][] , int n) {
  		for(int i = 0; i < n; i++) {
  			for(int j = 0; j < n; j++) {
  				if(i == j) {
  					arr[i][j] = 'X';
  				}
  			}
  		}
  	}
  	
  	public static void fillminus(char arr[][], int col) {
  		for(int i = 0; i < arr.length; i++) {
  			if(i != col) {
  				arr[i][col] = '-';
  			}
  		}
  	}
  	
  	public static void fillequal(char arr[][], int row) {
  		for(int i = 0; i < arr.length; i++) {
  			if(i != row) {
  				arr[row][i] = '=';
  			}
  		}
  	}
  	
  	public static void main(String[] args) throws IOException {
  		int test = s.nextInt();
  		while(test-->0) {
  			int n = s.nextInt();
  			String str = s.next();
  			int arr[] = new int[n];
  			for(int i = 0; i < n; i++) {
  				if(str.charAt(i) == '1') {
  					arr[i] = 1;
  				}else {
  					arr[i] = 2;
  				}
  			}
  			char dp[][] = new char[n][n];
  			ArrayList<Integer> one = new ArrayList<>();
  			ArrayList<Integer> two = new ArrayList<>();
  			for(int i = 0; i < n ; i++) {
  				if(arr[i] == 1) {
  					one.add(i);
  				}else {
  					two.add(i);
  				}
  			}
  			fill(dp,n);
  //			System.out.println(two);
  			if(two.size() == 1 || two.size() == 2) {
  				out.println("NO");
  			}else {
  				out.println("YES");
  				for(int i = 0; i < one.size(); i++) {
  					fillequal(dp, one.get(i));
  				}
  				int size = two.size();
  				int i = 0;
  				while(i < size) {
  					int j = (i+1)%size;
  					int p1 = two.get(i);
  					int p2 = two.get(j);
  					dp[p1][p2] = '+';
  					dp[p2][p1] = '-';
  					i++;
  				}
  				
  				for(int r = 0; r < n; r++) {
  					for(int c = 0; c < n; c++) {
  						if(dp[r][c] != '+' && dp[r][c] != '-' && dp[r][c] != '=' && dp[r][c] != 'X') {
  							dp[r][c] = '=';
  						}
  					}
  				}
  				
  				for(int r = 0; r < n; r++) {
  					for(int c = 0; c < n; c++) {
  						out.print(dp[r][c]);
  					}
  					out.println("");
  				}
  				
  			}
  		}
  		out.close();
  	}
  	
  
  	public static ArrayList<Integer> seive(int n){
  		ArrayList<Integer> list = new ArrayList<>();
  		int arr[] = new int[n+1];
  		for(int i = 2; i <= n; i++) {
  			if(arr[i] == 1) {
  				continue;
  			}else {
  				list.add(i);
  				for(int j = i*i; j <= n; j = j + i) {
  					arr[j] = 1;
  				}
  			}
  		}
  		return list;
  	}
  
  	public static long gcd(long a, long b){
  		if(a > b)
  			a = (a+b)-(b=a);
  		if(a == 0L)
  			return b;
  		return gcd(b%a, a);
  	}
  
  	public static void swap(int[] arr, int i, int j) {
  		arr[i] = arr[i] ^ arr[j];
  		arr[j] = arr[j] ^ arr[i];
  		arr[i] = arr[i] ^ arr[j];
  	}
  
  	public static boolean isPrime(long n){
  		if(n < 2) return false;
  		if(n == 2 || n == 3) return true;
  		if(n%2 == 0 || n%3 == 0) return false;
  		long sqrtN = (long)Math.sqrt(n)+1;
  		for(long i = 6L; i <= sqrtN; i += 6) {
  			if(n%(i-1) == 0 || n%(i+1) == 0) return false;
  		}
  		return true;
  	}
  
  	public static ArrayList<Integer> findDiv(int N){
  		//gens all divisors of N
  		ArrayList<Integer> ls1 = new ArrayList<Integer>();
  		ArrayList<Integer> ls2 = new ArrayList<Integer>();
  		for(int i=1; i <= (int)(Math.sqrt(N)+0.00000001); i++)
  			if(N%i == 0)
  			{
  				ls1.add(i);
  				ls2.add(N/i);
  			}
  		Collections.reverse(ls2);
  		for(int b: ls2)
  			if(b != ls1.get(ls1.size()-1))
  				ls1.add(b);
  		return ls1;
  	}
  
  	public static long power(long x, long y, long p){
  		//0^0 = 1
  		long res = 1L;
  		x = x%p;
  		while(y > 0)
  		{
  			if((y&1)==1)
  				res = (res*x)%p;
  			y >>= 1;
  		x = (x*x)%p;
  		}
  		return res;
  	}
  
  	public static void printintarr(int[] arr) {
  		for(int i = 0; i < arr.length; i++) {
  			System.out.print(arr[i]+" ");
  		}
  	}
  
  	public static void printlongarr(long[] arr) {
  		for(int i = 0; i < arr.length; i++) {
  			System.out.print(arr[i]+" ");
  		}
  	}
  
  	public static void printdoublearr(double[] arr) {
  		for(int i = 0; i < arr.length; i++) {
  			System.out.print(arr[i]+" ");
  		}
  	}
  
  	public static void printintarr(int arr[][]) {
  		for(int i = 0 ; i < arr.length; i++) {
  			for(int j = 0; j < arr[0].length; j++) {
  				System.out.print(arr[i][j]+" ");
  			}
  			System.out.println();
  		}
  	}
  
  	public static void printlongarr(long arr[][]) {
  		for(int i = 0 ; i < arr.length; i++) {
  			for(int j = 0; j < arr[0].length; j++) {
  				System.out.print(arr[i][j]+" ");
  			}
  			System.out.println();
  		}
  	}
  
  	public static void printdoublearr(double arr[][]) {
  		for(int i = 0 ; i < arr.length; i++) {
  			for(int j = 0; j < arr[0].length; j++) {
  				System.out.print(arr[i][j]+" ");
  			}
  			System.out.println();
  		}
  	}
  
  	public static void takeintarr(int arr[]) {
  		for(int i = 0; i < arr.length; i++) {
  			arr[i] = s.nextInt();
  		}
  	}
  
  	public static void takeintarr(int arr[][]) {
  		for(int i = 0; i < arr.length; i++) {
  			for(int j = 0; j < arr[0].length; j++) {
  				arr[i][j] = s.nextInt();
  			}
  		}
  	}
  }