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.io.ByteArrayInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.InputMismatchException;
  import java.util.List;
  
  public class B {
  	private static PrintWriter out = new PrintWriter(System.out);
  
  	public static void solve() {
  		In in = new In();
  		int tests = in.ni();
  		outer: while (tests-- > 0) {
  			int n = in.ni();
  			char[] s = in.ns().toCharArray();
  			int count = 0;
  			for (char c : s) {
  				if (c == '2')
  					count++;
  			}
  			if (count > 0 && count <= 2) {
  				out.println("NO");
  				continue outer;
  			}
  			char D = '=', W = '+', L = '-';
  			char[][] ans = new char[n][n];
  			for (char[] row : ans)
  				Arrays.fill(row, D);
  			List<Integer> list = new ArrayList<>();
  			for (int i = 0; i < n; i++) {
  				if (s[i] == '2')
  					list.add(i);
  			}
  			for (int i = 0; i < n; i++) {
  				ans[i][i] = 'X';
  			}
  			for (int i = 0; i < list.size(); i++) {
  				int winner = list.get(i);
  				int loser = list.get((i + 1) % list.size());
  				ans[winner][loser] = W;
  				ans[loser][winner] = L;
  			}
  			out.println("YES");
  			for (char[] row : ans) {
  				out.println(String.valueOf(row));
  			}
  		}
  	}
  
  	public static void main(String[] args) throws IOException {
  		// long start = System.nanoTime();
  		solve();
  		// System.out.println("Elapsed: " + (System.nanoTime() - start) / 1000000 +
  		// "ns");
  		out.flush();
  	}
  
  	@SuppressWarnings("unused")
  	private static class In {
  		final private static int BUFFER_SIZE = 1024;
  		private byte[] buf;
  		private InputStream is;
  		private int buflen;
  		private int bufptr;
  
  		public In() {
  			is = System.in;
  			buf = new byte[BUFFER_SIZE];
  			buflen = bufptr = 0;
  		}
  
  		public In(String input) {
  			is = new ByteArrayInputStream(input.getBytes());
  			buf = new byte[BUFFER_SIZE];
  			buflen = bufptr = 0;
  		}
  
  		public int readByte() {
  			if (bufptr >= buflen) {
  				try {
  					buflen = is.read(buf);
  				} catch (IOException ioe) {
  					throw new InputMismatchException();
  				}
  				bufptr = 0;
  			}
  			if (buflen <= 0)
  				return -1;
  			return buf[bufptr++];
  		}
  
  		public boolean isSpaceChar(int c) {
  			return !(c >= 33 && c <= 126);
  		}
  
  		public int skip() {
  			int b;
  			while ((b = readByte()) != -1 && isSpaceChar(b))
  				;
  			return b;
  		}
  
  		/* Next character */
  		public char nc() {
  			return (char) skip();
  		}
  
  		/* Next double */
  		public double nd() {
  			return Double.parseDouble(ns());
  		}
  
  		/* Next string */
  		public String ns() {
  			final StringBuilder sb = new StringBuilder();
  			int b = skip();
  			while (!isSpaceChar(b)) {
  				sb.appendCodePoint(b);
  				b = readByte();
  			}
  			return sb.toString();
  		}
  
  		/* Next integer */
  		public int ni() {
  			boolean minus = false;
  			int num = 0;
  			int b;
  			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
  				;
  			if (b == '-') {
  				minus = true;
  				b = readByte();
  			}
  			while (b >= '0' && b <= '9') {
  				num = num * 10 + (b - '0');
  				b = readByte();
  			}
  			return minus ? -num : num;
  		}
  
  		/* Next long */
  		public long nl() {
  			boolean minus = false;
  			long num = 0;
  			int b;
  			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
  				;
  			if (b == '-') {
  				minus = true;
  				b = readByte();
  			}
  			while (b >= '0' && b <= '9') {
  				num = num * 10 + (b - '0');
  				b = readByte();
  			}
  			return minus ? -num : num;
  		}
  
  		/* Next integer 1D array */
  		public Integer[] nia(int n) {
  			final Integer[] arr = new Integer[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = ni();
  			return arr;
  		}
  
  		/* Next long 1D array */
  		public long[] nla(int n) {
  			final long[] arr = new long[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = nl();
  			return arr;
  		}
  
  		/* Next string 1D array */
  		public String[] nsa(int n) {
  			final String[] arr = new String[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = ns();
  			return arr;
  		}
  
  		/* Next char 1D array */
  		public char[] nca(int n) {
  			final char[] arr = new char[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = nc();
  			return arr;
  		}
  
  		/* Next double 1D array */
  		public double[] nda(int n) {
  			final double[] arr = new double[n];
  			for (int i = 0; i < n; i++)
  				arr[i] = nc();
  			return arr;
  		}
  
  		/* Next integer matrix */
  		public int[][] nim(int n, int m) {
  			final int[][] arr = new int[n][m];
  			for (int i = 0; i < n; i++)
  				for (int j = 0; j < m; j++)
  					arr[i][j] = ni();
  			return arr;
  		}
  
  		/* Next long matrix */
  		public long[][] nlm(int n, int m) {
  			final long[][] arr = new long[n][m];
  			for (int i = 0; i < n; i++)
  				for (int j = 0; j < m; j++)
  					arr[i][j] = nl();
  			return arr;
  		}
  
  		/* Next string matrix */
  		public String[][] nsm(int n, int m) {
  			final String[][] arr = new String[n][m];
  			for (int i = 0; i < n; i++)
  				for (int j = 0; j < m; j++)
  					arr[i][j] = ns();
  			return arr;
  		}
  
  		/* Next char matrix */
  		public char[][] ncm(int n, int m) {
  			final char[][] arr = new char[n][m];
  			for (int i = 0; i < n; i++)
  				for (int j = 0; j < m; j++)
  					arr[i][j] = nc();
  			return arr;
  		}
  
  		/* Next double matrix */
  		public double[][] ndm(int n, int m) {
  			final double[][] arr = new double[n][m];
  			for (int i = 0; i < n; i++)
  				for (int j = 0; j < m; j++)
  					arr[i][j] = nd();
  			return arr;
  		}
  
  		public static void log(Object... o) {
  			System.out.println(Arrays.deepToString(o));
  		}
  	}
  
  }
  