#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  ;
}
 