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 com.company;
  
  import java.io.*;
  import java.lang.reflect.Array;
  import java.text.DecimalFormat;
  import java.util.*;
  
  public class Main {
  
      static boolean[] primecheck = new boolean[1000002];
  
      public static void main(String[] args) throws IOException {
          OutputStream outputStream = System.out;
          FastReader in = new FastReader();
          PrintWriter out = new PrintWriter(outputStream);
          PROBLEM solver = new PROBLEM();
          int t = 1;
          t = in.nextInt();
          for (int i = 0; i < t; i++) {
              solver.solve(in, out);
          }
          out.close();
      }
  
      public static int count1(char[] s){
          int ctr = 0;
          for (int i = 0; i < s.length; i++) {
              if(s[i] == '1') ctr++;
          }
          return ctr;
      }
      public static int count2(char[] s) {
          int ctr = 0;
          for (int i = 0; i < s.length; i++) {
              if (s[i] == '2') ctr++;
          }
          return ctr;
      }
  
  
  
      static class PROBLEM {
  
          public void solve(FastReader in, PrintWriter out) {
  
              int n = in.nextInt();
              char[] s = in.nextLine().toCharArray();
  
              if(count2(s)>0 && count2(s)<3) out.println("NO");
              else{
                  out.println("YES");
                  char[][] a = new char[n][n];
                  for (int i = 0; i < n; i++) {
                      Arrays.fill(a[i], '0');
                  }
                  for (int i = 0; i < n; i++) {
                      a[i][i] = 'X';
                  }
                  ArrayList<Integer> al = new ArrayList<>();
                  for (int i = 0; i < s.length; i++) {
                      if(s[i] == '2') al.add(i);
                  }
  
                  for (int i = 0; i < al.size(); i++) {
                      int l = al.get(i);
  
                      if(i == al.size()-1){
                          int r = al.get(0);
                          a[l][r] = '+';
                          a[r][l] = '-';
                      }else{
                          int r = al.get(i+1);
                          a[l][r] = '+';
                          a[r][l] = '-';
                      }
                  }
  
                  for (int i = 0; i < n; i++) {
                      for (int j = 0; j < n; j++) {
                          if(a[i][j] == '0') a[i][j] = '=';
                      }
                  }
  
                  for (int i = 0; i < n; i++) {
                      for (int j = 0; j < n; j++) {
                          out.print(a[i][j]);
                      }
                      out.println();
                  }
              }
  
  //            int n = in.nextInt();
  //            int[] a = in.readArray(n);
  //
  //            a = mergeSort(a);
  //            boolean isValid = true;
  //
  //            for (int i = 0; i < n-1; i++) {
  //                if(a[i+1]-a[i]>1){
  //                    isValid = false;
  //                    break;
  //                }
  //            }
  //            int ans = 0;
  //
  //            if(isValid){
  //                int m =998244353;
  //                int max = a[n-1],maxL = 0, cntMaxL = 0, cntMax = 0;
  //                for (int i = n-1; i >= 0 ; i--) {
  //                    if(a[i] != max && maxL == 0){
  //                        maxL = a[i];
  //                    }else cntMax++;
  //                    if(maxL != 0){
  //                        if(a[i] == maxL) cntMaxL++;
  //                        else break;
  //                    }
  //                }
  //
  //                if(cntMax>1){
  //                    ans = factorial(n, m);
  //                    ans = ((ans%m) * (n%m)) %m;
  //                }else{
  //                    int rem = n - cntMax-cntMaxL;
  //                    int nowRem = rem;
  //                    long sub = 0;
  //                    while(nowRem>0){
  //                        sub+= (nPr(rem, nowRem, m) * factorial(n-1-nowRem, m));
  //                        nowRem--;
  //                    }
  //                    ans = factorial(n-1,m);
  //                    ans = ((ans%m) * ((n-1)%m)) %m;
  //                    ans = (int)(((ans%m) - (sub%m) + m) % m);
  //                }
  //            }
  //            out.println(ans);
          }
      }
  
      static int nPr(int n, int r, int m){
          int num = factorial(n, m);
          int den = factorial(r, m);
          den*=factorial(n-r, m);
  
          return num/den * factorial(r, m);
      }
  
      static int factorial(int n, int m){
          int ans = 1;
          while(n>0){
              ans = ((ans%m)*(n*m))%m;
              n--;
          }
          return ans;
      }
  
      static boolean isPalindromeI(int n){
  
          int d = 0;
          int y = n;
          while(y>0){
              d++;
              y/=10;
          }
  
          int[] a = new int[d];
          for (int i = 0; i < d; i++) {
              a[i] = n%10;
              n/=10;
          }
  
          System.out.println(Arrays.toString(a));
          for (int i = 0; i < d / 2; i++) {
              if(a[i] != a[d-i-1]) return false;
          }
          return true;
      }
  
      static long gcd(long a, long b) {
          if (b == 0) return a;
          return gcd(b, a % b);
      }
  
      static boolean isSquare(double a) {
          boolean isSq = false;
          double b = Math.sqrt(a);
          double c = Math.sqrt(a) - Math.floor(b);
  
          if (c == 0) isSq = true;
  
          return isSq;
      }
  
      static int exponentMod(int A, int B, int C) {
  
          // Base cases
          if (A == 0)
              return 0;
          if (B == 0)
              return 1;
  
          // If B is even
          long y;
          if (B % 2 == 0) {
              y = exponentMod(A, B / 2, C);
              y = (y * y) % C;
          }
  
          // If B is odd
          else {
              y = A % C;
              y = (y * exponentMod(A, B - 1,
                      C) % C) % C;
          }
  
          return (int) ((y + C) % C);
      }
  
  
      static class pair implements Comparable<pair>{
          int x,y;
          pair(int xi, int yi){
              x=xi;
              y=yi;
          }
          @Override
          public int compareTo(pair other){
              if(this.x>other.x){return 1;}
              if(this.x<other.x){return -1;}
              if(this.y>other.y){return 1;}
              if(this.y<other.y){return -1;}
              return 0;
          }
      }
  
  //    public static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
  //        public U x;
  //        public V y;
  //
  //        public Pair(U x, V y) {
  //            this.x = x;
  //            this.y = y;
  //        }
  //
  //        public int hashCode() {
  //            return (x == null ? 0 : x.hashCode() * 31) + (y == null ? 0 : y.hashCode());
  //        }
  //
  //        public boolean equals(Object o) {
  //            if (this == o)
  //                return true;
  //            if (o == null || getClass() != o.getClass())
  //                return false;
  //            Pair<U, V> p = (Pair<U, V>) o;
  //            return (x == null ? p.x == null : x.equals(p.x)) && (y == null ? p.y == null : y.equals(p.y));
  //        }
  //
  //        public int compareTo(Pair<U, V> b) {
  //            int cmpU = x.compareTo(b.x);
  //            return cmpU != 0 ? cmpU : y.compareTo(b.y);
  //        }
  //
  //        public String toString() {
  //            return String.format("(%s, %s)", x.toString(), y.toString());
  //        }
  //
  //    }
  
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
  
          public FastReader() {
              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());
          }
  
          char nextChar() {
              return next().charAt(0);
          }
  
          boolean nextBoolean() {
              return !(nextInt() == 0);
          }
          // boolean nextBoolean(){return Boolean.parseBoolean(next());}
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
  
          public int[] readArray(int size) {
              int[] array = new int[size];
              for (int i = 0; i < size; i++) array[i] = nextInt();
              return array;
          }
  
      }
  
      private static int[] mergeSort(int[] array) {
  
          //array.length replaced with ctr
          int ctr = array.length;
          if (ctr <= 1) {
              return array;
          }
  
          int midpoint = ctr / 2;
  
          int[] left = new int[midpoint];
          int[] right;
  
          if (ctr % 2 == 0) {
              right = new int[midpoint];
          } else {
              right = new int[midpoint + 1];
          }
  
          for (int i = 0; i < left.length; i++) {
              left[i] = array[i];
          }
  
          for (int i = 0; i < right.length; i++) {
              right[i] = array[i + midpoint];
          }
  
          int[] result = new int[array.length];
  
          left = mergeSort(left);
          right = mergeSort(right);
  
          result = merge(left, right);
  
          return result;
      }
  
      private static int[] merge(int[] left, int[] right) {
  
          int[] result = new int[left.length + right.length];
          int leftPointer = 0, rightPointer = 0, resultPointer = 0;
  
          while (leftPointer < left.length || rightPointer < right.length) {
  
              if (leftPointer < left.length && rightPointer < right.length) {
  
                  if (left[leftPointer] < right[rightPointer]) {
                      result[resultPointer++] = left[leftPointer++];
                  } else {
                      result[resultPointer++] = right[rightPointer++];
                  }
              } else if (leftPointer < left.length) {
                  result[resultPointer++] = left[leftPointer++];
              } else {
                  result[resultPointer++] = right[rightPointer++];
              }
          }
          return result;
      }
  
      public static void Sieve(int n) {
  
          Arrays.fill(primecheck, true);
          primecheck[0] = false;
          primecheck[1] = false;
  
          for (int i = 2; i * i < n + 1; i++) {
              if (primecheck[i]) {
                  for (int j = i * 2; j < n + 1; j += i) {
                      primecheck[j] = false;
                  }
              }
          }
      }
  }
  
  
  