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: // Compete Against yourself :)
  
  import java.io.*;
  import java.util.*;
  
  public class TaskB {
      static FastReader fr = new FastReader();
      StringBuilder op = new StringBuilder();
  
      public void run() {
          int tt=fr.nextInt();
          while(tt-->0){
              int n=fr.nextInt();
              String s=fr.next();
              int ones=0,twos=0;
              for(int i=0;i<n;i++){
                  if(s.charAt(i)=='1'){
                      ones+=1;
                  }
                  else{
                      twos+=1;
                  }
              }
              if(twos==0){
                  op.append("YES\n");
                  for(int i=0;i<n;i++) {
                      for (int j = 0; j < n; j++) {
                          if (i == j) {
                              op.append("X");
                          } else {
                              op.append("=");
                          }
                      }
                      op.append("\n");
                  }
              }
              else if(twos<=2){
                  op.append("NO\n");
              }
              else{
                  op.append("YES").append("\n");
                  char [][] ans = new char[n][n];
                  for(int i=0;i<n;i++){
                      Arrays.fill(ans[i],'=');
                  }
                  int st=-1;
                  int bt=-1;
                  for(int i=0;i<n;i++){
                      if(s.charAt(i)=='2'){
                          if(st==-1){
                              st=i;
                              bt=i;
                          }
                          else{
                              ans[st][i]='+';
                              ans[i][st]='-';
                              st=i;
                          }
                      }
                  }
                  ans[st][bt]='+';
                  ans[bt][st]='-';
  
                  for(int i=0;i<n;i++){
                      ans[i][i]='X';
                  }
                  for(char row[]:ans){
                      for(char ele:row){
                          op.append(ele);
                      }
                      op.append("\n");
                  }
              }
          }
          System.out.println(op);
      }
  
      public static void main(String[] args) {
          new TaskB().run();
      }
      //math related functions
  
      //gcd
      private long gcd(long a, long b) {
          if (a == 0) {
              return b;
          } else {
              return gcd(b % a, a);
          }
      }
  
      //lcm
      private long lcm(long a, long b) {
          return (a * b) / gcd(a, b);
      }
  
      //exponential power
      private long power(long a, long b) {
          if (a == 1 || b == 0) {
              return 1;
          }
          long res = 1;
          while (b != 0) {
              if (b % 2 == 1) {
                  res = res * a;
              }
              b /= 2;
              a *= a;
          }
          return res;
      }
  
      // euler totient function copied from
      // https://www.geeksforgeeks.org/eulers-totient-function/
  
      private int phi(int n) {
          // Initialize result as n
          double result = n;
  
          // Consider all prime factors of n and for
          // every prime factor p, multiply result
          // with (1 - 1/p)
          for (int p = 2; p * p <= n; ++p) {
              // Check if p is a prime factor.
              if (n % p == 0) {
                  // If yes, then update n and result
                  while (n % p == 0)
                      n /= p;
                  result *= (1.0 - (1.0 / (double) p));
              }
          }
  
          // If n has a prime factor greater than sqrt(n)
          // (There can be at-most one such prime factor)
          if (n > 1)
              result *= (1.0 - (1.0 / (double) n));
  
          return (int) result;
      }
  
  
      //binary search related functions
      private int lowerBound(int[] a, int key) {
          int ans = -1;
          int low = 0;
          int high = a.length - 1;
          while (low <= high) {
              int mid = (low + high) >>> 1;
              if (a[mid] >= key) {
                  ans = mid;
                  high = mid - 1;
              } else {
                  low = mid + 1;
              }
          }
          return ans;
      }
  
      private int upperBound(int[] a, int key) {
          int ans = -1;
          int low = 0;
          int high = a.length - 1;
          while (low <= high) {
              int mid = (low + high) >>> 1;
              if (a[mid] > key) {
                  ans = mid;
                  high = mid - 1;
              } else {
                  low = mid + 1;
              }
          }
          return ans;
      }
  
      //reverse
      private void reverse(int[] a, int s, int e) {
          for (int i = s, j = e; i <= j; i++, j--) {
              int temp = a[i];
              a[i] = a[j];
              a[j] = temp;
          }
      }
  
      private void reverse(long[] a, int s, int e) {
          for (int i = s, j = e; i <= j; i++, j--) {
              long temp = a[i];
              a[i] = a[j];
              a[j] = temp;
          }
      }
  
      //sorting
      private void sort(int[] a) {
          List<Integer> ls = new ArrayList<Integer>();
          for (int x : a) {
              ls.add(x);
          }
          Collections.sort(ls);
          for (int i = 0; i < a.length; i++) {
              a[i] = ls.get(i);
          }
      }
  
      private void sort(long[] a) {
          List<Long> ls = new ArrayList<Long>();
          for (long x : a) {
              ls.add(x);
          }
          Collections.sort(ls);
          for (int i = 0; i < a.length; i++) {
              a[i] = ls.get(i);
          }
      }
  
      private void sortInRangeInt(int[] a, int s, int e) {
          List<Integer> ls = new ArrayList<>();
          for (int i = s; i <= e; i++) ls.add(a[i]);
          Collections.sort(ls);
          for (int i = s; i <= e; i++) {
              a[i] = ls.get(i);
          }
      }
  
      private void sortInRangeLong(long[] a, int s, int e) {
          List<Long> ls = new ArrayList<>();
          for (int i = s; i <= e; i++) ls.add(a[i]);
          Collections.sort(ls);
          for (int i = s; i <= e; i++) {
              a[i] = ls.get(i);
          }
      }
  
      //Fast I/O
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() {
              br = new BufferedReader(new InputStreamReader(System.in));
              st = null;
          }
  
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException ie) {
                      ie.printStackTrace();
                  }
              }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
  
          double nextDouble() {
              return Double.parseDouble(next());
          }
  
          ;
  
          int[] readIntArray(int n) {
              int[] a = new int[n];
              for (int i = 0; i < n; i++) {
                  a[i] = nextInt();
              }
              return a;
          }
  
          long[] readLongArray(int n) {
              long[] a = new long[n];
              for (int i = 0; i < n; i++) {
                  a[i] = nextLong();
              }
              return a;
          }
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException ie) {
                  ie.printStackTrace();
              }
              return str;
          }
      }
  }
  