#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define time cerr<<"Time taken : " <<(float)clock()/CLOCKS_PER_SEC <<" secs"<<"\n" ;
#define F first
#define S second
#define pb push_back
typedef long long int ll ;
const ll INF = (ll)1e18 ;
const ll MOD = (ll)1e9 + 7 ;
/*-------------------------------------------------------------------------------------------------------------*/
void solve() {
ll n;
cin >> n;
string str ;
cin >> str;
string arr[n+1] ;
for(ll i=1;i<=n; i++){
for(ll j=1;j<=n;j++){
if(i==j){
arr[i][j] = 'X' ;
}
else{
arr[i][j] = '=' ;
}
}
}
vector<ll>one,two ;
for(ll i=0; i<n; i++){
if(str[i]=='1'){
one.pb(i+1) ;
}
else{
two.pb(i+1) ;
}
}
if(two.size()<=2 && !two.empty()){
cout <<"NO\n" ;
return ;
}
sort(two.begin(),two.end()) ;
ll p = two.size() ;
if(two.size() > 0) {
for (ll i = 0; i < p-1 ; i++) {
// cout << two[i] << " " << two[i + 1] << " ";
arr[two[i]][two[i+1]] = '+' ;
arr[two[i+1]][two[i]] = '-' ;
}
arr[two[p-1]][two[0]] = '+' ;
arr[two[0]][two[p-1]] = '-' ;
}
// cout <<"\n" ;
// arr[two[p-1]][two[0]] = '+' ;
bool check = 1 ;
for(ll i=1;i<=n;i++){
for(ll j=1;j<=n; j++){
if(i==j){
if(arr[i][j]!='X'){
check = 0 ;
break ;
}
}
if(!check){
break ;
}
}
if(!check){
break ;
}
}
if(!check){
cout <<"NO\n" ;
return ;
}
else{
cout <<"YES\n" ;
for(ll i=1;i<=n;i++){
for(ll j=1;j<=n; j++){
cout << arr[i][j] ;
}
cout <<"\n" ;
}
}
//cout <<"\n";
}
int32_t main() {
fast ; time;
int t = 1;
cin >> t;
while (t--) {
solve() ;
}
return 0 ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGZhc3QgICAgICAgICAgICAgICAgICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOyAgY2luLnRpZShOVUxMKTsKI2RlZmluZSB0aW1lICAgICAgICAgICAgICAgICAgICBjZXJyPDwiVGltZSB0YWtlbiA6ICIgPDwoZmxvYXQpY2xvY2soKS9DTE9DS1NfUEVSX1NFQyA8PCIgc2VjcyI8PCJcbiIgIDsKI2RlZmluZSBGICAgICAgICAgICAgICAgICAgICAgICBmaXJzdAojZGVmaW5lIFMgICAgICAgICAgICAgICAgICAgICAgIHNlY29uZAojZGVmaW5lIHBiICAgICAgICAgICAgICAgICAgICAgIHB1c2hfYmFjawp0eXBlZGVmIGxvbmcgbG9uZyBpbnQgICAgICAgICAgIGxsICA7CgoKY29uc3QgbGwgSU5GID0gKGxsKTFlMTggICA7CmNvbnN0IGxsIE1PRCA9IChsbCkxZTkgKyA3IDsKCgovKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLwoKdm9pZCBzb2x2ZSgpIHsKCiAgICBsbCBuOwogICAgY2luID4+IG47CgogICAgc3RyaW5nIHN0ciA7CiAgICBjaW4gPj4gc3RyOwoKICAgIHN0cmluZyBhcnJbbisxXSAgOwoKICAgIGZvcihsbCBpPTE7aTw9bjsgaSsrKXsKICAgICAgICBmb3IobGwgaj0xO2o8PW47aisrKXsKCiAgICAgICAgICAgIGlmKGk9PWopewogICAgICAgICAgICAgICAgYXJyW2ldW2pdID0gJ1gnIDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlewogICAgICAgICAgICAgICAgYXJyW2ldW2pdID0gJz0nICA7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgdmVjdG9yPGxsPm9uZSx0d28gOwoKICAgIGZvcihsbCBpPTA7IGk8bjsgaSsrKXsKICAgICAgICBpZihzdHJbaV09PScxJyl7CiAgICAgICAgICAgIG9uZS5wYihpKzEpICA7CiAgICAgICAgfQogICAgICAgIGVsc2V7CiAgICAgICAgICAgIHR3by5wYihpKzEpICA7CiAgICAgICAgfQogICAgfQoKICAgIGlmKHR3by5zaXplKCk8PTIgJiYgIXR3by5lbXB0eSgpKXsKICAgICAgICBjb3V0IDw8Ik5PXG4iICA7CiAgICAgICAgcmV0dXJuIDsKICAgIH0KCiAgICBzb3J0KHR3by5iZWdpbigpLHR3by5lbmQoKSkgIDsKCgogICAgbGwgcCA9IHR3by5zaXplKCkgIDsKICAgIGlmKHR3by5zaXplKCkgPiAwKSB7CgogICAgICAgIGZvciAobGwgaSA9IDA7IGkgPCBwLTEgOyBpKyspIHsKLy8gICAgICAgICAgICBjb3V0IDw8IHR3b1tpXSA8PCAiICIgPDwgdHdvW2kgKyAxXSA8PCAiICI7CiAgICAgICAgICAgIGFyclt0d29baV1dW3R3b1tpKzFdXSA9ICcrJyAgOwogICAgICAgICAgICBhcnJbdHdvW2krMV1dW3R3b1tpXV0gPSAnLScgIDsKICAgICAgICB9CgogICAgICAgIGFyclt0d29bcC0xXV1bdHdvWzBdXSA9ICcrJyAgOwogICAgICAgIGFyclt0d29bMF1dW3R3b1twLTFdXSA9ICctJyA7CiAgICB9CiAgICAvLyAgIGNvdXQgPDwiXG4iICA7CgovLyAgICBhcnJbdHdvW3AtMV1dW3R3b1swXV0gPSAnKycgIDsKCiAgICBib29sIGNoZWNrID0gMSAgOwoKICAgIGZvcihsbCBpPTE7aTw9bjtpKyspewogICAgICAgIGZvcihsbCBqPTE7ajw9bjsgaisrKXsKCiAgICAgICAgICAgIGlmKGk9PWopewogICAgICAgICAgICAgICAgaWYoYXJyW2ldW2pdIT0nWCcpewogICAgICAgICAgICAgICAgICAgIGNoZWNrID0gMCA7CiAgICAgICAgICAgICAgICAgICAgYnJlYWsgOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CgogICAgICAgICAgICBpZighY2hlY2spewogICAgICAgICAgICAgICAgYnJlYWsgIDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZighY2hlY2spewogICAgICAgICAgICBicmVhayAgOwogICAgICAgIH0KICAgIH0KCiAgICBpZighY2hlY2spewogICAgICAgIGNvdXQgPDwiTk9cbiIgIDsKICAgICAgICByZXR1cm4gOwogICAgfQogICAgZWxzZXsKICAgICAgICBjb3V0IDw8IllFU1xuIiAgOwogICAgICAgIGZvcihsbCBpPTE7aTw9bjtpKyspewogICAgICAgICAgICBmb3IobGwgaj0xO2o8PW47IGorKyl7CiAgICAgICAgICAgICAgICBjb3V0IDw8IGFycltpXVtqXSA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY291dCA8PCJcbiIgIDsKICAgICAgICB9CiAgICB9CgoKCgoKICAgIC8vY291dCA8PCJcbiI7Cn0KCgppbnQzMl90IG1haW4oKSB7CgogICAgZmFzdCA7IHRpbWU7CgoKCiAgICBpbnQgdCA9IDE7CiAgICBjaW4gPj4gdDsKCiAgICB3aGlsZSAodC0tKSB7CiAgICAgICAgc29sdmUoKSAgOwogICAgfQoKCiAgICByZXR1cm4gMCAgOwp9CsKg