#include <bits/stdc++.h>
using namespace std;
int t, n;
string k;
int a[555], b[555];
char x[555][555];
void tachso(string k) {
  int dem = 0;
  for (int i = n; i >= 0; i--) {
    b[++dem] = (int)(k[i] - '0');
  }
}
int main() {
  cin >> t;
  while (t--) {
    int dem1 = 0, dem2 = 0;
    cin >> n;
    cin >> k;
    k = "l" + k;
    for (int i = 0; i <= n + 1; i++) {
      a[i] = 0;
      b[i] = 0;
    }
    for (int i = 0; i <= n + 1; i++)
      for (int j = 0; j <= n + 1; j++) x[i][j] = 0;
    tachso(k);
    for (int i = n; i >= 1; i--) a[n - i + 1] = b[i];
    for (int i = 1; i <= n; i++)
      if (a[i] == 1)
        dem1++;
      else
        dem2++;
    if (dem2 <= 2 && dem2 > 0)
      cout << "NO"
           << "\n";
    else {
      cout << "YES"
           << "\n";
      if (dem2 == 0) {
        for (int i = 1; i <= n; i++)
          for (int j = 1; j <= n; j++)
            if (i == j)
              x[i][j] = 'X';
            else {
              x[i][j] = '=';
              x[j][i] = '=';
            }
      } else {
        for (int i = 1; i <= n; i++) {
          bool ok = true;
          for (int j = 1; j <= n; j++) {
            if (i == j)
              x[i][j] = 'X';
            else {
              if (a[i] == 1) {
                x[i][j] = '=';
                x[j][i] = '=';
              } else {
                if (a[j] == 2)
                  if (ok && x[j][i] != '+') {
                    x[i][j] = '+';
                    ok = false;
                  } else {
                    x[i][j] = '-';
                    x[j][i] = '+';
                  }
              }
            }
          }
        }
      }
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) cout << x[i][j];
        cout << endl;
      }
    }
  }
  return 0;
}
