## Algorithm

B. Chess Tournament
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A chess tournament will be held soon, where n chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.

Each of the players has their own expectations about the tournament, they can be one of two types:

1. a player wants not to lose any game (i. e. finish the tournament with zero losses);
2. a player wants to win at least one game.

You have to determine if there exists an outcome for all the matches such that all the players meet their expectations. If there are several possible outcomes, print any of them. If there are none, report that it's impossible.

Input

The first line contains a single integer t (1t2001≤�≤200) — the number of test cases.

The first line of each test case contains one integer n (2n502≤�≤50) — the number of chess players.

The second line contains the string s (|s|=n|�|=�si{1,2}��∈{1,2}). If si=1��=1, then the i-th player has expectations of the first type, otherwise of the second type.

Output

For each test case, print the answer in the following format:

In the first line, print NO if it is impossible to meet the expectations of all players.

Otherwise, print YES, and the matrix of size n×n�×� in the next n lines.

The matrix element in the i-th row and j-th column should be equal to:

• +, if the i-th player won in a game against the j-th player;
• -, if the i-th player lost in a game against the j-th player;
• =, if the i-th and j-th players' game resulted in a draw;
• X, if i=j�=�.
Example
input
Copy
3
3
111
2
21
4
2122
output
Copy
YES
X==
=X=
==X
NO
YES
X--+
+X++
+-X-
--+X

## Code Examples

### #1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int t;
cin>>t;
while(t--){
int n;
cin>>n;
string a;
cin>>a;
int count = 0;
for(int i = 0; i < n; i++){
if(a[i] == '2'){
count++;
}
}
if(count == 1 || count == 2){
cout<<"NO"<<endl;
continue;
}
char arr[n][n];
bool check;
for(int i = 0; i < n; i++){
check = true;
for(int j = i; j < n; j++){
if(i == j){
arr[i][j] = 'X';
continue;
}
else if((a[i] == '1' && a[j] == '1') || (a[i] == '1' && a[j] == '2') || (a[i] == '2' && a[j] == '1')){
arr[i][j] = '=';
arr[j][i] = '=';
continue;
}
else if(a[i] == '2' && a[j] == '2'){
if(check){
check = false;
arr[i][j] = '+';
arr[j][i] = '-';
}
else{
arr[i][j] = '-';
arr[j][i] = '+';
}
continue;
}
}
}
cout<<"YES"<<endl;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cout<<arr[i][j];
}
cout<<endl;
}
}

}
Copy The Code &

Input

cmd
3
3
111
2
21
4
2122

Output

cmd
YES
X==
=X=
==X
NO
YES
X--+
+X++
+-X-
--+X