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: import java.util.*;
  import java.io.*;
  public class Transform_the_experssion  {
  	static Scanner sc=new Scanner(System.in);
  	static PrintWriter pw=new PrintWriter(System.out);	
  
  	public static void main(String[] args) throws IOException, InterruptedException {
  	int t=sc.nextInt();
  	while(t-->0) {
  		int n=sc.nextInt();
  		String s=sc.next();
  		int x=-1,y=-1;
  		StringBuilder ans=new StringBuilder();
  		char [][]arr=new char [n][n];
  		boolean f=false;
  		for(int i=0;i<n;i++) {
  			int count=0;
  			for(int j=i+1;j<n;j++) {
  				if(s.charAt(i)=='2') {
  					if(s.charAt(j)=='1') {
  						arr[i][j]='=';
  					}
  					else if(s.charAt(j)=='2' && count==0) {
  						arr[i][j]='+';
  						count++;
  					}
  					else {
  						arr[i][j]='-';
  					}
  				}
  				else {
  					arr[i][j]='=';
  				}
  			}
  		}
  		for(int i=0;i<n;i++) {
  			int count=0;
  			for(int j=i-1;j>=0;j--) {
  				if(arr[j][i]=='-')
  					arr[i][j]='+';
  				else if(arr[j][i]=='=')
  					arr[i][j]='=';
  				else if(arr[j][i]=='+') {
  					arr[i][j]='-';
  				}
  			}
  		}
  		for(int i=0;i<n;i++) {
  			int count=0;
  			for(int j=0;j<n;j++) {
  				if(i==j) {
  					ans.append("X");
  					continue;
  				}
  				else {
  					ans.append(arr[i][j]);
  					if(arr[i][j]=='+')
  						count++;
  			}
  			}
  			ans.append('\n');
  			if(s.charAt(i)=='2' && count==0) {
  				f=true;
  				break;
  			}
  		}
  		if(f)
  			pw.println("NO");
  		else {
  			pw.println("YES");
  			pw.print(ans);
  		}
  	}
  		
  		
      
  	pw.flush();
  	}
  	static class PairPoint{
  		pair p1;
  		pair p2;
  		public PairPoint(pair p1,pair p2) {
  			this.p1=p1;
  			this.p2=p2;
  		}
          public boolean inter(pair p) {
          	long x1=Math.max(p1.x, p2.x),x2=Math.min(p1.x, p2.x);
          	long y1=Math.max(p1.y, p2.y),y2=Math.min(p1.y, p2.y);
          	if((p.x>=x2 && p.x<=x1) && (p.y>=y2 && p.y<=y1))
          		return true;
          	return false;
   		}
  		/*public void swap(PairPoint pp) {
  			pp.p1.swap(this.p1);
  			pp.p2.swap(this.p2);
  		}
  		*/
  		public String toString () {
  			return p1.toString()+p2.toString();
  		}
  		public boolean equals (PairPoint pp) {
  			if(p1.equals(pp.p1) && p2.equals(pp.p2))
  				return true;
  			return false;
  		}
  		
  	}
  	static class pair implements Comparable<pair> {
  		long x;
  		long y;
   
  		public pair(long x, long y) {
  			this.x = x;
  			this.y = y;
  		}
   
  		public String toString() {
  			return x + " " + y;
  		}
   
  		public boolean equals(Object o) {
  			if (o instanceof pair) {
  				pair p = (pair) o;
  				return p.x == x && p.y == y;
  			}
  			return false;
  		}
   
  		public int hashCode() {
  			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
  		}
   
  		public int compareTo(pair other) {
  			if (this.x == other.x) {
  				return Long.compare(this.y, other.y);
  			}
  			return Long.compare(other.x, this.x);
  		}
  	}
  	/*
  	 * public class MST_Prim {
  
  	static ArrayList<Edge>[] adjList;
  	static int V;
  	
  	static int prim()		//O(E log E)
  	{
  		int mst = 0;
  		boolean[] visited = new boolean[V];
  		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
  		pq.add(new Edge(0, 0));
  		while(!pq.isEmpty())
  		{
  			Edge cur = pq.remove();
  			if(visited[cur.node])
  				continue;
  			visited[cur.node] = true;
  			mst += cur.cost;
  			for(Edge nxt: adjList[cur.node])
  				if(!visited[nxt.node])
  					pq.add(nxt);
  		}	
  		return mst;
  	}
  	
  	static class Edge implements Comparable<Edge>
  	{
  		int node, cost;
  		
  		Edge(int a, int b) { node = a; cost = b; }
  		
  		public int compareTo(Edge e) { return cost - e.cost; }
  		
  	}
  	
  }
  	 */
  	static class UnionFind {                                              
  		int[] p, rank, setSize;
  		int numSets;
  
  		public UnionFind(int N) 
  		{
  			numSets=N;
  			p = new int[N+1];
  			rank = new int[N+1];
  			setSize = new int[N+1];
  			for (int i = 0; i <= N; i++) {  p[i] = i; setSize[i] = 1; }
  		}
  
  		public int findSet(int i) { return p[i] == i ? i : (p[i] = findSet(p[i])); }
  
  		public boolean isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  
  		public void join(int i, int j) 
  		{ 
  			if (isSameSet(i, j)) 
  				return;
  			numSets--; 
  			int x = findSet(i), y = findSet(j);
  			if(rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
  			else
  			{	p[x] = y; setSize[y] += setSize[x];
  				if(rank[x] == rank[y]) rank[y]++; 
  			} 
  		}
  
  		public int numDisjointSets() { return numSets; }
  
  		public int sizeOfSet(int i) { return setSize[findSet(i)]; }
  		public String toString () {
  			return Arrays.toString(p)+"   "+Arrays.toString(rank);
  		}
  	}
  	
  	/*static class pair implements Comparable<pair> {
  		long x;
  		long y;
   
  		public pair(long x, long y) {
  			this.x = x;
  			this.y = y;
  		}
   
  		public String toString() {
  			return x + " " + y;
  		}
   
  		public boolean equals(Object o) {
  			if (o instanceof pair) {
  				pair p = (pair) o;
  				return p.x == x && p.y == y;
  			}
  			return false;
  		}
   
  		public int hashCode() {
  			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
  		}
   
  		public int compareTo(pair other) {
  			if (this.x == other.x) {
  				return Long.compare(this.y, other.y);
  			}
  			return Long.compare(this.x, other.x);
  		}
  	}*/
  	/*static class Edge implements Comparable<Edge>
  	{
  		int u, v, w;
  
  		Edge(int a, int b, int c) {	u = a; v = b; w = c; }
  
  		public int compareTo(Edge e) { return w - e.w; }
  	}
     static class MST_Kruskal {
  
  	static Edge[] edgeList;
  	static int V;
  
  	static int kruskal()		//O(E log E)
  	{
  		int mst = 0;
  		Arrays.sort(edgeList);
  		UnionFind uf = new UnionFind(V);
  
  		for(Edge e: edgeList)
  			if(uf.union(e.u, e.v))
  				mst += e.w;
  		return mst;
  	}
  
  	*/
  
  	
  	static class Scanner {
  		StringTokenizer st;
  		BufferedReader br;
   
  		public Scanner(InputStream s) {
  			br = new BufferedReader(new InputStreamReader(s));
  		}
   
  		public Scanner(FileReader r) {
  			br = new BufferedReader(r);
  		}
  		public String readAllLines(BufferedReader reader) throws IOException {
  		    StringBuilder content = new StringBuilder();
  		    String line;
  		    
  		    while ((line = reader.readLine()) != null) {
  		        content.append(line);
  		        content.append(System.lineSeparator());
  		    }
  
  		    return content.toString();
  		}
  		public String next() throws IOException {
  			while (st == null || !st.hasMoreTokens())
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
   
  		public int nextInt() throws IOException {
  			return Integer.parseInt(next());
  		}
   
  		public long nextLong() throws IOException {
  			return Long.parseLong(next());
  		}
   
  		public String nextLine() throws IOException {
  			return br.readLine();
  		}
   
  		public double nextDouble() throws IOException {
  			String x = next();
  			StringBuilder sb = new StringBuilder("0");
  			double res = 0, f = 1;
  			boolean dec = false, neg = false;
  			int start = 0;
  			if (x.charAt(0) == '-') {
  				neg = true;
  				start++;
  			}
  			for (int i = start; i < x.length(); i++)
  				if (x.charAt(i) == '.') {
  					res = Long.parseLong(sb.toString());
  					sb = new StringBuilder("0");
  					dec = true;
  				} else {
  					sb.append(x.charAt(i));
  					if (dec)
  						f *= 10;
  				}
  			res += Long.parseLong(sb.toString()) / f;
  			return res * (neg ? -1 : 1);
  		}
   
  		public long[] nextlongArray(int n) throws IOException {
  			long[] a = new long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextLong();
  			return a;
  		}
   
  		public Long[] nextLongArray(int n) throws IOException {
  			Long[] a = new Long[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextLong();
  			return a;
  		}
   
  		public int[] nextIntArray(int n) throws IOException {
  			int[] a = new int[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextInt();
  			return a;
  		}
   
  		public Integer[] nextIntegerArray(int n) throws IOException {
  			Integer[] a = new Integer[n];
  			for (int i = 0; i < n; i++)
  				a[i] = nextInt();
  			return a;
  		}
   
  		public boolean ready() throws IOException {
  			return br.ready();
  		}
   
  	}
   
  }