#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  string s;
  int count;
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> s;
    count = 0;
    char expec[n];
    for (int i = 0; i < n; ++i) {
      if (s[i] == '1')
        expec[i] = 'D';
      else {
        expec[i] = 'W';
        count++;
      }
    }
    if (count > 0 && count < 3) {
      cout << "NO\n";
      continue;
    }
    cout << "YES\n";
    char mat[n][n];
    for (int i = 0; i < n; ++i) {
      for (int j = i; j < n; ++j) {
        if (i == j) {
          mat[i][j] = 'X';
          continue;
        }
        if (expec[i] == 'D' || expec[j] == 'D') {
          mat[i][j] = '=';
          mat[j][i] = '=';
        } else if (expec[i] == 'W') {
          expec[i] = 'L';
          mat[i][j] = '+';
          mat[j][i] = '-';
        } else {
          mat[i][j] = '-';
          mat[j][i] = '+';
          expec[j] = 'L';
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        cout << mat[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}
