#include <bits/stdc++.h>
using namespace std;
char result[55][55];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    string s;
    cin >> n >> s;
    vector<int> ww;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) {
        result[i][j] = result[j][i] = '=';
        if (i == j) result[i][j] = 'X';
      }
    for (int i = 0; i < n; ++i)
      if (s[i] == '2') ww.push_back(i + 1);
    if (ww.size() > 0 && ww.size() <= 2) {
      cout << "NO\n";
      continue;
    }
    for (int i = 0; i < ww.size(); ++i) {
      int nxt = i + 1;
      if (i == ww.size() - 1) nxt = 0;
      result[ww[i]][ww[nxt]] = '+';
      result[ww[nxt]][ww[i]] = '-';
    }
    cout << "YES\n";
    for (int i = 1; i <= n; cout << "\n", ++i)
      for (int j = 1; j <= n; ++j) cout << result[i][j];
  }
  return 0;
}
