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: //package Java;
  import java.io.*;
  import java.text.DecimalFormat;
  import java.util.*;
  import java.util.Map.Entry;
  
  public class Main {
  	static final PrintWriter out = new PrintWriter(System.out, true);
      static final FastScanner sc = new FastScanner();
      public static void main(String[] args)  {
  		  int t=sc.nextInt();
  		    while(t-->0) {
  		    	int n=sc.nextInt();
  		    	String s=sc.next();
  	    		int a=0,b=0;
  	    		ArrayList<Integer>h=new ArrayList<>();
  	    		for(int i=0;i<n;i++) {
  	    			if(s.charAt(i)=='1') a++;
  	    			else {
  	    				h.add(i);
  	    				b++;
  	    			}
  	    		}
  	    		char ans[][]=new char[n][n];
  	    		for(int i=0;i<n;i++) {
  	    			for(int j=0;j<n;j++) {
  	    				if(i!=j) ans[i][j]='%';
  	    				else ans[i][j]='X';
  	    			}
  	    		}
  	    		boolean flag=false;
  	    		if((b==1)||(b==2)) {
  	    			out.println("NO");
  	    			flag=true;
  	    		}
  	    		if(flag==false) {
  		    		int k=1;
  		    		for(int i=0;i<n;i++) {
  		    			if(s.charAt(i)=='1') {
  		    				for(int j=0;j<n;j++) {
  		    					if(i!=j) ans[i][j]='=';
  		    				}
  		    				for(int j=0;j<n;j++) {
  		    					if(i!=j) ans[j][i]='=';
  		    				}
  		    			}
  		    		}
  		    		for(int i:h) {
  		    					ans[i][h.get(k)]='+';
  		    					ans[h.get(k)][i]='-';
  		    					k++;
  		    					if(k==h.size()) break;
  		    		}
  		    		if(h.size()>=2) ans[h.get(0)][h.get(h.size()-1)]='-';
  		    		if(h.size()>=2) ans[h.get(h.size()-1)][h.get(0)]='+';
  		    		for(int i=0;i<n;i++) {
  		    			for(int j=0;j<n;j++) {
  		    				if(ans[i][j]=='%') ans[i][j]='=';
  		    			}
  		    		}
  		    		out.println("YES");
  		    		for(int i=0;i<n;i++) {
  		    			for(int j=0;j<n;j++) {
  		    				out.print(ans[i][j]);
  		    			}
  		    			out.println();
  		    		}
  	    		}
  		    }
      		out.close();
      }
  	  static void sieveOfEratosthenes(int n,int a[],boolean prime[])
  	    {
  	        for (int i = 0; i <= n; i++)
  	            prime[i] = true;
  	        	int ii=0;
  	        for (int p = a[ii];ii<n;ii++)
  	        {
  	            if (prime[p] == true)
  	            {
  	                for (int i = p * p; i <= n; i += p)
  	                    prime[i] = false;
  	            }
  	        }
  	    }
  	  public static double logx(long m,int x)
  	    {
  	        double result = (double)(Math.log(m) / Math.log(x));
  	  
  	        return result;
  	    }
  	     static double setPrecision(double ans,int k){
  	    	 double y=Math.pow(10,k);
  	    	 return Math.round(ans*y)/y;
  	     }
  	  public static double log2(double m)
  	    {
  	        double result = (double)(Math.log(m) / Math.log(2));
  	  
  	        return result;
  	    }
  	public static void sort(long[] arr){//because Arrays.sort() uses quicksort which is in worst O(n^2)
  		//Collections.sort() uses merge sort
  		ArrayList<Long> ttttt = new ArrayList<Long>();
  		for(long y: arr)ttttt.add(y);Collections.sort(ttttt);
  		for(int i=0; i < arr.length; i++)arr[i] = ttttt.get(i);
  	}
  	public static void sort(int[] arr){//because Arrays.sort() uses quicksort which is dumb
  		//Collections.sort() uses merge sort
  		ArrayList<Integer> ttttt = new ArrayList<>();
  		for(int y: arr)ttttt.add(y);Collections.sort(ttttt);
  		for(int i=0; i < arr.length; i++)arr[i] = ttttt.get(i);
  	}
  	static boolean check(double[] a,double m,int n,int k) {
  		int ans=0;
  		for(int i=0;i<n;i++) {
  			ans+=(Math.floor(a[i]/m));
  			if(ans>=k) return true;
  		}
  		return ans>=k;
  	}
  	     static boolean isKthBitSet(long n, int k) { 
  			if ((n & (1 << (k - 1))) > 0) 
  			return true;
  			else
  			return false;
  			
  		 } 
  	     static long modpow(long a,long b,int m) {
  	    	 if(b==0) return 1;
  	    	 if(b==1) return a;
  	    	 long ans=0;
  	    	 long t=modpow(a,b/2,m);
  	    	 ans=modmul(t,t,m);
  	    	 if(b%2!=0) ans=modmul(a,ans,m);
  	    	 return ans;
  	     }
  		static long modmul(long a,long b,int m) {
  			return mod(mod(a,m)*mod(b,m),m);
  		}
  		static long mod(long x,int m) {
  			return ((x%m)+m)%m;
  		}
  		 static int octaltodecimal(int deciNum)
  		    {
  		        int octalNum = 0, countval = 1;
  		        int dNo = deciNum;
  		        while (deciNum != 0) {
  		 
  		            // decimals remainder is calculated
  		            int remainder = deciNum % 8;
  		 
  		            // storing the octalvalue
  		            octalNum += remainder * countval;
  		 
  		            // storing exponential value
  		            countval = countval * 10;
  		            deciNum /= 8;
  		        }
  		       return octalNum;
  		    }
  		
  	  public static int floorSqrt(int x) 
  	    { 
  	        // Base Cases 
  	        if (x == 0 || x == 1) 
  	            return x; 
  	  
  	        // Do Binary Search for floor(sqrt(x)) 
  	        int start = 1, end = x, ans=0; 
  	        while (start <= end) 
  	        { 
  	            int mid = (start + end) / 2; 
  	  
  	            // If x is a perfect square 
  	            if (mid*mid == x) 
  	                return mid; 
  	  
  	            // Since we need floor, we update answer when mid*mid is 
  	            // smaller than x, and move closer to sqrt(x) 
  	            if (mid*mid < x) 
  	            { 
  	                start = mid + 1; 
  	                ans = mid; 
  	            } 
  	            else   // If mid*mid is greater than x 
  	                end = mid-1; 
  	        } 
  	        return ans; 
  	    } 
  		static int div(int n,int b) {
  			int g=-1;
  			for(int i=2;i<=Math.sqrt(n);i++) {
  				if(n%i==0&&i!=b) {
  					g=i;
  					break;
  				}
  			}
  			return g;
  		}
  	 
  	  
  	  public static int gcd(int a, int b) 
  	    { 
  	        if (a == 0) 
  	            return b; 
  	          
  	        return gcd(b%a, a); 
  	    } 
  	   public static int lcm(int a, int b)  
  	  {  
  	     return (a*b)/gcd(a, b);  
  	  }  
  	   public static boolean isPrime1(int n) {
             if (n <= 1) {
                 return false;
             }
             if (n == 2) {
                 return true;
             }
             for (int i = 2; i <= Math.sqrt(n) + 1; i++) {
                 if (n % i == 0) {
                     return false;
                 }
             }
             return true;
         }
         public static boolean isPrime(int n) {
             if (n <= 1) {
                 return false;
             }
             if (n == 2) {
                 return true;
             }
             if (n % 2 == 0) {
                 return false;
             }
             for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2) {
                 if (n % i == 0) {
                     return false;
                 }
             }
             return true;
         }
  	      
         static class FastScanner {
             BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
             StringTokenizer strToken = new StringTokenizer("");
             String next() {
          	   while (!strToken.hasMoreTokens()) {
          		   try {
          			   strToken = new StringTokenizer(input.readLine()); 
          		   }  catch (IOException e) { 
          			    e.printStackTrace();
          			  } 
          	   } return strToken.nextToken(); 
          	}
             String nextLine() {
          	   String strrrrr = ""; try {
          		   strrrrr = input.readLine(); 
          	   } catch (IOException e) {
          			   e.printStackTrace(); 
          		}
          	   return strrrrr; 
             }
             int nextInt() {
          	   return Integer.parseInt(next()); 
          	}
             int[] nextIntArray(int n) {
          	   int[] a = new int[n]; 
          	   for (int i = 0; i < n; i++) a[i] = nextInt(); 
          	   return a; 
             }
             long nextLong() {
          	   return Long.parseLong(next()); 
          	}
             long[] nextLongArray(int n) {
          	   long[] a = new long[n];
          	   for (int i = 0; i < n; i++) a[i] = nextLong(); 
          	   return a; 
          	}
             double nextDouble() {
          	   return Double.parseDouble(next()); 
             }
         }
  }
  //
  //class Pair{
  //  int value;
  //  int distance;
  //  Pair(int value,int distance){
  //      this.value=value;
  //      this.distance=distance;
  //  }
  //  
  //}
  //class sortbydistance implements Comparator<Pair>{
  //
  //	@Override
  //	public int compare(Pair o1, Pair o2) {
  //		return o1.distance-o2.distance;
  //	}
  //	
  //}
  //class Solution
  //{
  //  static int[] dijkstra(int n, ArrayList<ArrayList<ArrayList<Integer>>> adj, int S)
  //  {
  //  	 PriorityQueue<Pair>set=new PriorityQueue<>(new sortbydistance());
  //      int dis[]=new int[n];
  //      Arrays.fill(dis,Integer.MAX_VALUE);
  //      dis[0]=0;
  //      while(set.isEmpty()==false) {
  //      	Pair p=set.poll();
  //      	int u=p.value;
  //      	for(int i=0;i<adj.get(u).size();i++) {
  //      		int v=adj.get(u).get(i).get(0);
  //      		int wt=adj.get(u).get(i).get(1);
  //      		if(dis[v]>dis[u]+wt) {
  //      			if(dis[v]!=Integer.MAX_VALUE) {
  //      				set.remove(new Pair(dis[v],v));
  //      			}
  //      			dis[v]=dis[u]+wt;
  //      			set.add(new Pair(v,dis[v]));
  //      		}
  //      		
  //      	}
  //      }
  //      
  //      
  //      return dis;
  //  }
  //}
  //