#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int a = 0, b = 0;
    for (int i = 0; i < n; i++) {
      if (str[i] == '1')
        a++;
      else
        b++;
    }
    if (b == 1 || b == 2) {
      cout << "NO" << endl;
      continue;
    }
    cout << "YES" << endl;
    char arr[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j)
          arr[i][j] = 'X';
        else if (str[i] == '1' || str[j] == '1')
          arr[i][j] = '=';
        else
          arr[i][j] = '=';
      }
    }
    int ind[b];
    int k = 0;
    for (int i = 0; i < n; i++) {
      if (str[i] == '2') {
        ind[k] = i;
        k++;
      }
    }
    if (b != 0) {
      for (int i = 0; i < k - 1; i++) {
        int c = ind[i];
        int d = ind[i + 1];
        arr[c][d] = '+';
        arr[d][c] = '-';
      }
      int e = ind[0];
      int f = ind[b - 1];
      arr[f][e] = '+';
      arr[e][f] = '-';
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cout << arr[i][j];
      }
      cout << endl;
    }
  }
}
