#include <bits/stdc++.h>
using namespace std;
void testCases() {
  long long n;
  cin >> n;
  string str;
  cin >> str;
  std::vector<long long> v, res;
  char arr[n + 1][n + 1];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      arr[i][j] = '#';
    }
  }
  long long two = 0, one = 0;
  for (long long i = 0; i < n; i++) {
    if (str[i] == '1') {
      one++;
      v.push_back(i);
    } else {
      two++;
      res.push_back(i);
    }
  }
  if (one == n) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        if (i == j) {
          arr[i][j] = 'X';
        } else {
          arr[i][j] = '=';
        }
      }
    }
    cout << "YES\n";
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        cout << arr[i][j];
      }
      cout << "\n";
    }
    return;
  } else if (two == n) {
    if (n == 2) {
      cout << "NO\n";
      return;
    } else {
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < n; j++) {
          if (i == j) arr[i][j] = 'X';
        }
      }
      for (long long i = 0; i < n; i++) {
        long long a = (i + 1) % n;
        arr[i][a] = '+';
        arr[a][i] = '-';
      }
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < n; j++) {
          if (arr[i][j] == '#') {
            arr[i][j] = '=';
          }
        }
      }
      cout << "YES\n";
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < n; j++) {
          cout << arr[i][j];
        }
        cout << "\n";
      }
      return;
    }
  } else {
    if (two <= 2) {
      cout << "NO\n";
    } else {
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < n; j++) {
          if (i == j) arr[i][j] = 'X';
        }
      }
      for (long long i = 0; i < v.size(); i++) {
        long long row = v[i];
        for (long long j = 0; j < n; j++) {
          if (row != j) arr[row][j] = '=';
        }
        for (long long j = 0; j < n; j++) {
          if (row != j) {
            arr[j][row] = '=';
          }
        }
      }
      long long m = res.size();
      for (long long i = 0; i < m; i++) {
        long long curr = res[i];
        long long next = res[(i + 1) % m];
        arr[curr][next] = '+';
        arr[next][curr] = '-';
      }
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < n; j++) {
          if (arr[i][j] == '#') {
            arr[i][j] = '=';
          }
        }
      }
      cout << "YES\n";
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j < n; j++) {
          cout << arr[i][j];
        }
        cout << "\n";
      }
      return;
    }
  }
  return;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long test = 1;
  cin >> test;
  for (long long cases = 1; cases <= test; cases++) {
    testCases();
  }
  return 0;
}
