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:

a player wants not to lose any game (i. e. finish the tournament with zero losses);

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$ ($1 \le t \le 200$) — the number of test cases.

The first line of each test case contains one integer $n$ ($2 \le n \le 50$) — the number of chess players.

The second line contains the string $s$ ($|s| = n$; $s_i \in \{1, 2\}$). If $s_i = 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 \times 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$.


-----Examples-----

Input
3
3
111
2
21
4
2122
Output
YES
X==
=X=
==X
NO
YES
X--+
+X++
+-X-
--+X


-----Note-----

None

Difficulty: EASY

Solutions:
t = int(input())
for test in range(t):
	n = int(input())
	matrix = [['='] * n for i in range(n)]
	for i in range(n):
		matrix[i][i] = 'X'
	exp = input()
	done = False
	for c in range(n):
		if exp[c] == '2':
			for i in range(n):
				if c != i and exp[i] == '2' and (matrix[i][c] == '='):
					matrix[i][c] = '-'
					matrix[c][i] = '+'
					break
			else:
				done = True
				print('NO')
	if not done:
		print('YES')
		for line in matrix:
			print(''.join(line))


m = []
for i in range(int(input())):
	n = int(input())
	e = input()
	m = [['=' for k in range(n)] for j in range(n)]
	for i in range(n):
		m[i][i] = 'X'
	two = len([j for j in e if j != '1'])
	twoi = [j for j in range(n) if e[j] != '1']
	if two == 1 or two == 2:
		print('NO')
		continue
	print('YES')
	for i in range(two):
		t1 = twoi[i]
		if i + 1 == len(twoi):
			t2 = twoi[0]
		else:
			t2 = twoi[i + 1]
		m[t1][t2] = '+'
		m[t2][t1] = '-'
	print('\n'.join([''.join(j) for j in m]))


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s.count('2') in [1, 2]:
		print('NO')
	else:
		print('YES')
		l = len(s)
		x = []
		for i in range(l):
			if s[i] != '1':
				x.append(i)
		l2 = 0
		for i in range(l):
			if s[i] == '1':
				print('=' * i + 'X' + '=' * (l - i - 1))
			else:
				ll = ['='] * l
				ll[i] = 'X'
				ll[x[l2 - 1]] = '-'
				ll[x[(l2 + 1) % len(x)]] = '+'
				l2 += 1
				print(''.join(ll))


for _ in range(int(input())):
	n = int(input())
	s = input()
	l = [['=' for i in range(n)] for j in range(n)]
	for i in range(n):
		l[i][i] = 'X'
	arr = []
	for i in range(n):
		if s[i] == '2':
			arr.append(i)
	if 0 < len(arr) <= 2:
		print('NO')
	else:
		print('YES')
		len_arr = len(arr)
		for i in range(len_arr):
			l[arr[i]][arr[(i + 1) % len_arr]] = '+'
			l[arr[(i + 1) % len_arr]][arr[i]] = '-'
		for i in l:
			print(''.join(i))


from os import path
from sys import stdin, stdout
if path.exists('tc.txt'):
	stdin = open('tc.txt', 'r')
from collections import defaultdict

def gmi():
	return map(int, stdin.readline().strip().split())

def gms():
	return map(str, stdin.readline().strip().split())

def gari():
	return list(map(int, stdin.readline().strip().split()))

def gart():
	return tuple(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(str, stdin.readline().strip().split()))

def gs():
	return stdin.readline().strip()

def gls():
	return list(stdin.readline().strip())

def gi():
	return int(stdin.readline())

def solve():
	(n, s) = (gi(), gs())
	mat = [['X'] * n for _ in range(n)]
	for i in range(n):
		si = s[i] == '1'
		already = False
		for j in range(i + 1, n):
			sj = s[j] == '1'
			if si and sj:
				mat[i][j] = mat[j][i] = '='
			elif si or sj:
				mat[i][j] = mat[j][i] = '='
			elif not already:
				(mat[i][j], mat[j][i]) = ('+', '-')
				already = True
			else:
				(mat[i][j], mat[j][i]) = ('-', '+')
	check = []
	for i in range(n):
		if s[i] == '1':
			check.append(False if '-' in mat[i] else True)
		else:
			check.append(True if '+' in mat[i] else False)
	if all(check):
		print('YES')
		for i in mat:
			print(''.join(i))
	else:
		print('NO')
tc = gi()
while tc:
	tc -= 1
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	g2 = [*filter(lambda x: s[x] == '2', range(n))]
	if 0 < len(g2) < 3:
		print('NO')
		continue
	print('YES')
	r = [n * ['='] for i in range(n)]
	for i in range(n):
		r[i][i] = 'X'
	for i in range(-1, len(g2) - 1):
		(j, k) = (g2[i], g2[i + 1])
		r[j][k] = '+'
		r[k][j] = '-'
	for i in r:
		print(''.join(i))


from sys import stdin

def solve():
	n = int(stdin.readline().strip())
	seq = stdin.readline().strip()
	type_1 = []
	type_2 = []
	for i in range(n):
		if seq[i] == '1':
			type_1.append(i)
		else:
			type_2.append(i)
	ans = [['=' for _ in range(n)] for _ in range(n)]
	for i in range(n):
		ans[i][i] = 'X'
	if len(type_2) > 2:
		for i in range(len(type_2) - 1):
			ans[type_2[i]][type_2[i + 1]] = '+'
			ans[type_2[i + 1]][type_2[i]] = '-'
		ans[type_2[-1]][type_2[0]] = '+'
		ans[type_2[0]][type_2[-1]] = '-'
		print('YES')
		for line in ans:
			print(''.join(line))
	elif len(type_2) == 0:
		print('YES')
		for line in ans:
			print(''.join(line))
	else:
		print('NO')
t = int(stdin.readline().strip())
for _ in range(t):
	solve()


t = input()
for k in range(int(t)):
	n = int(input())
	m = input()
	if m.count('2') in [2, 1]:
		print('NO')
	else:
		s = dict()
		for i in range(n):
			s[i] = ['='] * n
			s[i][i] = 'X'
		w = int()
		q = int()
		if '2' in m:
			w = m.index('2')
			q = w
			for i in range(w + 1, n):
				if m[i] == '2':
					s[w][i] = '+'
					s[i][w] = '-'
					w = i
			s[w][q] = '+'
			s[q][w] = '-'
		print('YES')
		for i in range(n):
			print(''.join(s[i]))


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = []
	ans = [['=' for j in range(n)] for i in range(n)]
	for i in range(n):
		ans[i][i] = 'X'
	for i in range(n):
		if s[i] == '2':
			a.append(i)
	l = set()
	if len(a) <= 2 and len(a) > 0:
		print('NO')
		continue
	elif len(a) == 0:
		print('YES')
		for i in range(n):
			print(''.join(ans[i]))
		continue
	for i in range(len(a) - 1):
		l.add((a[i], a[i + 1]))
	l.add((a[-1], a[0]))
	for i in l:
		ans[i[0]][i[1]] = '+'
		ans[i[1]][i[0]] = '-'
	print('YES')
	for i in range(n):
		print(''.join(ans[i]))


t = int(input())
for i in range(t):
	n = int(input())
	b = input()
	first = b.find('2')
	ans = {}
	if b.count('2') == 1 or b.count('2') == 2:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if b[i] == '1':
				pass
			else:
				j = i + 1
				while j < n:
					if b[j] == '2':
						(ans[i, j], ans[j, i]) = ('+', '-')
						break
					j += 1
				else:
					(ans[i, first], ans[first, i]) = ('+', '-')
		for i in range(n):
			for j in range(n):
				if i == j:
					print('X', end='')
				elif (i, j) in ans:
					print(ans[i, j], end='')
				else:
					print('=', end='')
			print()


for q_ in range(int(input())):
	n = int(input())
	mat = [['X' if i == j else '=' for j in range(n)] for i in range(n)]
	canlose = set()
	canwin = set()
	s = input()
	for i in range(n):
		if s[i] == '2':
			if n > 2:
				canlose.add(i)
			canwin.add(i)
	err = False
	n = 0
	while len(canwin) > 0:
		u = canwin.pop()
		v = next((x for x in canlose if mat[u][x] == '='), None)
		if v == None:
			n += 1
			v = next((i for (i, x) in enumerate(mat[u]) if x == '-'), None)
			if v == None or n > 100:
				err = True
				break
			canwin.add(v)
		mat[u][v] = '+'
		mat[v][u] = '-'
	if err:
		print('NO')
	else:
		print('YES', '\n'.join((''.join(l) for l in mat)), sep='\n')


for _ in range(int(input())):
	n = int(input())
	pref = list(map(int, list(input())))
	table = [['='] * n for __ in range(n)]
	for k in range(n):
		table[k][k] = 'X'
	if 0 < pref.count(2) <= 2:
		print('NO')
	else:
		print('YES')
		pref2 = []
		if pref.count(2) > 2:
			for i in range(len(pref)):
				if pref[i] == 2:
					pref2.append(i)
			for j in range(len(pref2) - 1):
				table[pref2[j]][pref2[j + 1]] = '+'
				table[pref2[j + 1]][pref2[j]] = '-'
			table[pref2[-1]][pref2[0]] = '+'
			table[pref2[0]][pref2[-1]] = '-'
		for line in table:
			print(''.join(line))


for _ in range(int(input())):
	n = int(input())
	ref = []
	total = [0] * n
	out = ['='] * n
	s = list(input())
	num = s.count('2')
	if num > 2 or num == 0:
		print('YES')
		for i in range(n):
			if s[i] == '2':
				ref.append(i)
				total[i] = 1
		for i in range(n):
			temp = out.copy()
			temp[i] = 'X'
			if total[i] == 1:
				a = ref.index(i)
				temp[ref[a - 1]] = '-'
				temp[ref[(a + 1) % num]] = '+'
			print(''.join(temp))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input()))
	twos = [i for i in range(n) if s[i] == 2]
	if 0 < len(twos) <= 2:
		print('NO')
		continue
	mat = [['=' for i in range(n)] for j in range(n)]
	nxt = 1
	for i in range(n):
		mat[i][i] = 'X'
		if s[i] == 1:
			continue
		mat[i][twos[nxt]] = '+'
		mat[twos[nxt]][i] = '-'
		nxt = (nxt + 1) % len(twos)
	mat = [''.join(i) for i in mat]
	print('YES')
	print(*mat, sep='\n')


def check(s, l):
	matrix = [['' for _ in range(l)] for _ in range(l)]
	for (idx, c1) in enumerate(s):
		no_wins = True
		for (jdx, c2) in enumerate(s):
			if matrix[idx][jdx]:
				if matrix[idx][jdx] == '+':
					no_wins = False
				continue
			if idx == jdx:
				matrix[idx][jdx] = 'X'
			elif c1 == '1' or c2 == '1':
				matrix[idx][jdx] = '='
				matrix[jdx][idx] = '='
			elif no_wins:
				matrix[idx][jdx] = '+'
				matrix[jdx][idx] = '-'
				no_wins = False
			else:
				matrix[idx][jdx] = '-'
				matrix[jdx][idx] = '+'
		if c1 == '2' and no_wins:
			return 'NO'
	print('YES')
	return '\n'.join([''.join(row) for row in matrix])
for _ in range(int(input())):
	l = int(input())
	s = input()
	print(check(s, l))


import math
import sys
import heapq
from collections import Counter, defaultdict, deque
from bisect import *
input = sys.stdin.readline
T = int(input())
while T > 0:
	T -= 1
	n = int(input())
	s = input()
	c2 = s.count('2')
	if 0 < c2 < 3:
		print('NO')
	else:
		print('YES')
		l = [[None for i in range(n)] for j in range(n)]
		for i in range(n):
			flag = 0
			for j in range(n):
				if i == j:
					l[i][j] = 'X'
				elif s[i] == '1' or s[j] == '1':
					l[i][j] = '='
				elif s[i] == s[j] == '2':
					if l[i][j] == None:
						if flag == 0:
							l[i][j] = '+'
							l[j][i] = '-'
							flag = 1
						else:
							l[i][j] = '-'
							l[j][i] = '+'
		for i in l:
			print(*i, sep='')


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	a = [['=' for i in range(n)] for j in range(n)]
	for i in range(n):
		a[i][i] = 'X'
	if s.count('2') < 3 and s.count('2') > 0:
		print('NO')
	else:
		print('YES')
		b = []
		for i in range(n):
			if s[i] == '2':
				b.append(i)
		for i in range(len(b)):
			a[b[i % len(b)]][b[(i + 1) % len(b)]] = '+'
			a[b[(i + 1) % len(b)]][b[i % len(b)]] = '-'
		for i in a:
			print(''.join(i))


def is_possible(players):
	cnt1 = 0
	cnt2 = 0
	for player in players:
		if player == '1':
			cnt1 += 1
		if player == '2':
			cnt2 += 1
	if cnt2 > 2 or cnt2 == 0:
		return True
	else:
		return False

def main():
	k = int(input())
	for _ in range(k):
		n = int(input())
		players = list(input())
		matrix = [[''] * n for i in range(n)]
		if is_possible(players):
			winners = []
			for i in range(n):
				matrix[i][i] = 'X'
				if players[i] == '1':
					for j in range(n):
						if i != j:
							matrix[i][j] = '='
							matrix[j][i] = '='
				else:
					winners.append(i)
			if len(winners) > 1:
				for i in range(1, len(winners)):
					matrix[winners[i - 1]][winners[i]] = '+'
					matrix[winners[i]][winners[i - 1]] = '-'
				matrix[winners[-1]][winners[0]] = '+'
				matrix[winners[0]][winners[-1]] = '-'
			for i in range(n):
				for j in range(n):
					if matrix[i][j] == '':
						matrix[i][j] = '='
			print('YES')
			for i in range(n):
				print(''.join(matrix[i]))
		else:
			print('NO')
main()


def int_input():
	a = int(input())
	return a

def int_list_input():
	a = list(map(int, input().split()))
	return a

def solve():
	n = int(input())
	s = input()
	l = []
	ans = [['=' for _ in range(n)] for _ in range(n)]
	for i in range(n):
		if s[i] != '1':
			l.append(i)
	if len(l) == 1 or len(l) == 2:
		print('NO')
		return
	print('YES')
	for i in range(n):
		ans[i][i] = 'X'
	for i in range(len(l)):
		if i == len(l) - 1:
			ans[l[i]][l[0]] = '+'
			ans[l[0]][l[i]] = '-'
		else:
			ans[l[i + 1]][l[i]] = '-'
			ans[l[i]][l[i + 1]] = '+'
	for row in ans:
		print(''.join(row))
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	t1 = [i for (i, c) in enumerate(s) if c == '1']
	t2 = [i for (i, c) in enumerate(s) if c == '2']
	if 1 <= len(t2) <= 2:
		print('NO')
		continue
	d = {}
	ans = [['=' for _ in range(n)] for _ in range(n)]
	for i in range(n):
		ans[i][i] = 'X'
	m = len(t2)
	for i in range(m):
		ans[t2[i]][t2[(i + 1) % m]] = '+'
		ans[t2[(i + 1) % m]][t2[i]] = '-'
	print('YES')
	print('\n'.join((''.join(r) for r in ans)))


import sys
import math
from collections import deque, Counter
from sys import stdin
int1 = lambda x: int(x) - 1
stinput = lambda : stdin.readline()[:-1]
ii = lambda : int(stinput())
mi = lambda : map(int, stdin.readline().split())
li = lambda : list(mi())
mi1 = lambda : map(int1, stdin.readline().split())
li1 = lambda : list(mi1())
mis = lambda : map(str, stdin.readline().split())
pr = print
rg = range
from collections import defaultdict
mod = 10 ** 9 + 7
Mod = 998244353
INF = 10 ** 18
ans = 0
t = ii()
for _ in range(t):
	n = ii()
	s = input()
	ans = [['='] * n for i in range(n)]
	for i in range(n):
		ans[i][i] = 'X'
	a = [-1] * 3
	cnt = 0
	for i in range(n):
		if s[i] == '2':
			if cnt < 3:
				a[cnt] = i
			cnt += 1
	if cnt == 0:
		print('YES')
		for i in ans:
			print(''.join(i))
	elif cnt < 3:
		print('NO')
	else:
		for i in range(3):
			(x, y) = (a[i], a[(i + 1) % 3])
			ans[x][y] = '+'
			ans[y][x] = '-'
		for i in range(a[2] + 1, n):
			if s[i] == '2':
				ans[i][a[0]] = '+'
				ans[a[0]][i] = '-'
		print('YES')
		for i in ans:
			print(''.join(i))


for _ in range(int(input())):
	n = int(input())
	s = input()
	dr = 0
	win = 0
	for i in range(n):
		if s[i] == '1':
			dr += 1
		else:
			win += 1
	if win > 0 and win < 3:
		print('NO')
		continue
	a = []
	for i in range(n):
		l = ['a'] * n
		a.append(l)
	for i in range(n):
		for j in range(n):
			if i == j:
				a[i][j] = 'X'
			elif s[i] == '2' and s[j] == '2' and (a[j][i] != '+'):
				a[i][j] = '+'
				a[j][i] = '-'
				break
	ok = 0
	for i in range(n):
		c = 0
		for j in range(n):
			if s[i] == '1' and a[i][j] == '-':
				ok = 1
				break
			if s[i] == '2' and a[i][j] == '+':
				c += 1
		if s[i] == '2' and c == 0:
			ok = 1
		if ok == 1:
			break
	if ok == 1:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			for j in range(n):
				if i == j:
					print('X', end='')
				elif a[i][j] != '+' and a[i][j] != '-' and (a[i][j] != 'X'):
					print('=', end='')
				else:
					print(a[i][j], end='')
			print()


t = int(input())
for time in range(t):
	player_num = int(input())
	player = input()
	listt = []
	typp = []
	for i in range(player_num):
		li = []
		typp.append(player[i])
		for j in range(player_num):
			if i == j:
				li.append('X')
			else:
				li.append('0')
		listt.append(li)
	for i in range(player_num):
		for j in range(player_num):
			if i == j:
				continue
			elif typp[i] == '1':
				if listt[j][i] == '0':
					if typp[j] == '2' or typp[j] == '3':
						listt[i][j] = '='
						listt[j][i] = '='
					else:
						listt[i][j] = '='
						listt[j][i] = '='
				else:
					continue
			elif typp[i] == '2':
				if listt[j][i] == '0':
					if typp[j] == '2' or typp[j] == '3':
						listt[i][j] = '+'
						listt[j][i] = '-'
						typp[i] = '3'
					else:
						listt[i][j] = '='
						listt[j][i] = '='
				else:
					continue
			elif typp[i] == '3':
				if listt[j][i] == '0':
					listt[i][j] = '-'
					listt[j][i] = '+'
					if typp[j] == '2':
						typp[j] = '3'
				else:
					continue
	if '2' in typp:
		print('NO')
	else:
		print('YES')
		for i in range(len(typp)):
			for j in range(len(typp)):
				print(listt[i][j], end='')
			print()


for _ in range(int(input())):
	n = int(input())
	s = input()
	p2 = []
	for i in range(n):
		if s[i] == '2':
			p2.append(i)
	if len(p2) == 1 or len(p2) == 2:
		print('NO')
		continue
	res = [['=' for i in range(n)] for i in range(n)]
	for i in range(n):
		res[i][i] = 'X'
	for i in range(len(p2)):
		a = p2[i]
		b = p2[(i + 1) % len(p2)]
		res[a][b] = '+'
		res[b][a] = '-'
	print('YES')
	for i in range(n):
		print(''.join((str(x) for x in res[i])))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input().rstrip())
	ans = 'YES'
	if 1 <= s.count('2') <= 2:
		ans = 'NO'
	print(ans)
	if ans == 'YES':
		ans = [['='] * n for _ in range(n)]
		for i in range(n):
			ans[i][i] = 'X'
		x = []
		for i in range(n):
			if s[i] == '2':
				x.append(i)
		for i in range(len(x)):
			(u, v) = (x[i], x[(i + 1) % len(x)])
			ans[u][v] = '+'
			ans[v][u] = '-'
		for ans0 in ans:
			print(''.join(ans0))


from itertools import combinations_with_replacement
t = int(input())

def count_matrix(m, player):
	pm = m[player]
	loses = pm.count('-')
	wins = pm.count('+')
	draws = pm.count('=')
	return (loses, wins, draws)

def satisfy_player(m, player, type):
	(loses, wins, _) = count_matrix(m, player)
	if type == '1':
		return loses == 0
	return wins >= 1

def gp2(p, n, type):
	if type == '1':
		for c in combinations_with_replacement('+=', n):
			c[p] = 'X'
			yield c

def gp3(p, types):
	if types[p] == '2':
		try:
			other = types.index('2', p + 1)
			m[p][other] = '+'
			m[other][p] = '-'
			return True
		except:
			other = types.index('2')
			if other < p:
				m[p][other] = '+'
				m[other][p] = '-'
			return False
	return True

def gen_play(m, n, types):
	for (p, t) in enumerate(types):
		m[p] = gp2(p, n, t)
		yield

def test_satisfaction():
	for (p, type) in enumerate(types):
		if not satisfy_player(m, p, type):
			return False
	return True

def main():
	for p in range(n):
		gp3(p, types)
	if not test_satisfaction():
		print('NO')
		return
	print('YES')
	for row in m:
		print(*row, sep='')
	return
for _ in range(t):
	n = int(input())
	m = [['=' for i in range(n)] for j in range(n)]
	types = input()
	for i in range(n):
		m[i][i] = 'X'
	main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	s = list(s)
	ans = []
	for i in range(n):
		temp = []
		for j in range(n):
			if i == j:
				temp.append('X')
			else:
				temp.append(0)
		ans.append(temp)
	co2 = 0
	for i in range(n):
		if s[i] == '2':
			co2 += 1
	if co2 == 0:
		print('YES')
		for i in range(n):
			for j in range(n):
				if ans[i][j] == 0:
					ans[i][j] = '='
				print(ans[i][j], end='')
			print('')
	elif co2 < 3:
		print('NO')
	else:
		print('YES')
		index = []
		for i in range(n):
			if s[i] == '2':
				index.append(i)
		for i in range(len(index) - 1):
			ans[index[i]][index[i + 1]] = '+'
			ans[index[i + 1]][index[i]] = '-'
		ans[index[-1]][index[0]] = '+'
		ans[index[0]][index[-1]] = '-'
		for i in range(n):
			for j in range(n):
				if ans[i][j] == 0:
					ans[i][j] = '='
				print(ans[i][j], end='')
			print('')


import sys

def I():
	return int(sys.stdin.readline().rstrip())

def MI():
	return map(int, sys.stdin.readline().rstrip().split())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def LI2():
	return list(map(int, sys.stdin.readline().rstrip()))

def S():
	return sys.stdin.readline().rstrip()

def LS():
	return list(sys.stdin.readline().rstrip().split())

def LS2():
	return list(sys.stdin.readline().rstrip())
t = I()
for _ in range(t):
	n = I()
	s = LI2()
	count1 = s.count(1)
	count2 = n - count1
	if count2 == 1 or count2 == 2:
		print('NO')
		continue
	print('YES')
	if count2 == 0:
		ANS = [['='] * n for _ in range(n)]
		for i in range(n):
			ANS[i][i] = 'X'
		for ans in ANS:
			print(''.join(ans))
	else:
		ANS = [[''] * n for _ in range(n)]
		X1 = []
		X2 = []
		for i in range(n):
			if s[i] == 1:
				X1.append(i)
			else:
				X2.append(i)
		for x1 in X1:
			for j in range(n):
				ANS[x1][j] = '='
				ANS[j][x1] = '='
		for i in range(count2):
			j0 = X2[i]
			j1 = X2[(i + 1) % count2]
			ANS[j0][j1] = '+'
			ANS[j1][j0] = '-'
		for i in range(n):
			for j in range(n):
				if ANS[i][j] == '':
					ANS[i][j] = '='
		for i in range(n):
			ANS[i][i] = 'X'
		for ans in ANS:
			print(''.join(ans))


t = int(input())
for hh in range(0, t):
	n = int(input())
	s = input()
	count2 = 0
	for i in range(0, n):
		if s[i] == '2':
			count2 += 1
	if count2 > 0 and count2 <= 2:
		print('NO')
	else:
		li = []
		for i in range(0, n):
			s1 = ''
			s1 += s
			li1 = list(s1)
			li.append(li1)
		for i in range(0, n):
			li[i][i] = 'X'
		for i in range(0, n):
			cnt = 0
			for j in range(i + 1, n):
				if s[i] == '1':
					li[i][j] = '='
					li[j][i] = '='
				elif s[j] == '1':
					li[i][j] = '='
					li[j][i] = '='
				elif cnt == 0:
					li[i][j] = '+'
					li[j][i] = '-'
					cnt += 1
				else:
					li[i][j] = '-'
					li[j][i] = '+'
					cnt += 1
		print('YES')
		for i in li:
			s1 = ''.join(i)
			print(s1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = [i for i in range(n) if s[i] == '2']
	if len(a) in (1, 2):
		print('NO')
	else:
		g = [['='] * n for _ in range(n)]
		for i in range(n):
			g[i][i] = 'X'
		if a:
			a.append(a[0])
			for i in range(len(a) - 1):
				g[a[i]][a[i + 1]] = '+'
				g[a[i + 1]][a[i]] = '-'
		print('YES')
		for v in g:
			print(''.join(v))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = []
	for i in range(n):
		if s[i] == '2':
			l.append(i)
	possible = len(l) == 0 or len(l) > 2
	if not possible:
		print('NO')
		continue
	print('YES')
	board = [['=' for _ in range(n)] for _ in range(n)]
	for i in range(n):
		board[i][i] = 'X'
	if len(l) > 0:
		l.append(l[0])
	for i in range(len(l) - 1):
		x = l[i]
		y = l[i + 1]
		board[x][y] = '+'
		board[y][x] = '-'
	for row in board:
		print(''.join(row))


for t in range(int(input())):
	n = int(input())
	s = list(input())
	c1 = 0
	c2 = 0
	for x in s:
		if x == '1':
			c1 += 1
		if x == '2':
			c2 += 1
	if c2 < 3 and c1 != n:
		print('NO')
		continue
	mat = [['X' if i == x else '=' for i in range(n)] for x in range(n)]
	for i in range(n):
		if s[i] == '2':
			for j in range(0, n):
				if s[j] == '2' and mat[i][j] == '=':
					mat[i][j] = '+'
					mat[j][i] = '-'
					break
	print('YES')
	for i in range(n):
		print(''.join(mat[i]))


from collections import Counter
for t in range(int(input())):
	n = int(input())
	s = input()
	count = Counter(s)
	if 1 <= count['2'] <= 2:
		print('NO')
	else:
		print('YES')
		matrix = [['X'] * n for _ in range(n)]
		for j in range(n):
			for i in range(j):
				if s[i] == '1' or s[j] == '1':
					matrix[i][j] = '='
					matrix[j][i] = '='
				else:
					matrix[i][j] = '+'
					matrix[j][i] = '-'
		if count['2'] > 2:
			minb = 0
			while s[minb] != '2':
				minb += 1
			maxb = n - 1
			while s[maxb] != '2':
				maxb -= 1
			matrix[minb][maxb] = '-'
			matrix[maxb][minb] = '+'
		for row in matrix:
			print(''.join(row))


n = int(input())
for i in range(n):
	cou = 0
	num = int(input())
	s = input()
	arr = [['=' for i in range(len(s))] for j in range(len(s))]
	for k in range(len(s)):
		arr[k][k] = 'X'
	node = []
	for k in range(len(s)):
		if s[k] == '1':
			node.append(k)
			cou += 1
	if num - cou < 3 and num - cou > 0:
		print('NO')
		continue
	else:
		print('YES')
	for k in range(len(s)):
		if k in node:
			continue
		for kk in range(len(s)):
			if kk in node or kk == k:
				continue
			if arr[k][kk] == '=':
				arr[k][kk] = '+'
				arr[kk][k] = '-'
				break
	for j in arr:
		print(''.join(j))


import sys

class BChessTournament:

	def solve(self, tc=0):
		for _ in range(int(input())):
			n = int(input())
			s = list(input().strip())
			mat = [['_'] * n for _ in range(n)]
			for i in range(n):
				for j in range(n):
					if i == j:
						mat[i][j] = 'X'
					elif s[i] == '1' or s[j] == '1':
						mat[i][j] = '='
			ok = True
			for i in range(n):
				if s[i] == '2':
					if mat[i].count('+') == 0:
						for j in range(n):
							if j == i:
								continue
							if mat[i][j] == '_':
								mat[i][j] = '+'
								mat[j][i] = '-'
								break
						else:
							ok = False
							break
					for j in range(n):
						if mat[i][j] == '_':
							mat[i][j] = '-'
							mat[j][i] = '+'
			if ok:
				print('YES')
				[print(*line, sep='') for line in mat]
			else:
				print('NO')
solver = BChessTournament()
input = sys.stdin.readline
solver.solve()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	two_count = s.count('2')
	one_count = s.count('1')
	games = n - 1
	draws = one_count
	if two_count:
		if two_count == 1 or games - one_count < 2:
			print('NO')
			continue
	mat = [['='] * n for _ in range(n)]
	for r in range(n):
		mat[r][r] = 'X'
	two_inds = []
	for i in range(n):
		if s[i] == '2':
			two_inds.append(i)
	size = len(two_inds)
	for (i, ind) in enumerate(two_inds):
		other = two_inds[(i + 1) % size]
		mat[ind][other] = '+'
		mat[other][ind] = '-'
	print('YES')
	for row in mat:
		print(''.join(row))


mod = 1000000007
from math import factorial, ceil, pow, sqrt, floor
from sys import stdin, stdout
from collections import defaultdict, Counter, deque
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline().strip('\n')
	if s.count('2') > 2 or s.count('2') == 0:
		print('YES')
		ans = []
		for i in range(n):
			if s[i] == '2':
				ans.append(i)
		h = len(ans)
		xi = []
		for i in range(h):
			if i + 1 == h:
				xi.append(ans[0])
			else:
				xi.append(ans[i + 1])
		k = 0
		for i in range(n):
			for j in range(n):
				if i == j:
					print('X', end='')
				elif s[i] == '1' or s[j] == '1':
					print('=', end='')
				elif j == xi[k % h]:
					print('+', end='')
				elif j == ans[(k + h - 1) % h]:
					print('-', end='')
				else:
					print('=', end='')
			if s[i] == '2':
				k = k + 1
			print()
	else:
		print('NO')


n = int(input())
for i in range(n):
	length = int(input())
	string = input()
	if '2' in string and string.count('2') <= 2:
		print('NO')
		continue
	print('YES')
	ans = [['=' for _ in range(length)] for _ in range(length)]
	for j in range(length):
		ans[j][j] = 'X'
	first = string.find('2')
	index = first
	if '2' in string:
		for j in range(length):
			index1 = string.find('2', index + 1)
			if index1 == -1:
				ans[index][first] = '+'
				ans[first][index] = '-'
			else:
				ans[index][index1] = '+'
				ans[index1][index] = '-'
			index = index1
	for j in range(length):
		print(''.join(ans[j]))


t = int(input())
for i in range(t):
	n = int(input())
	players = input()
	list_2 = []
	for (j, player) in enumerate(players):
		if player == '2':
			list_2.append(j)
	if len(list_2) == 1 or len(list_2) == 2:
		print('NO')
	else:
		print('YES')
		games = [['=' for x in range(n)] for x in range(n)]
		for j in range(n):
			games[j][j] = 'X'
		for (j, two) in enumerate(list_2):
			other = j + 1
			if j + 1 == len(list_2):
				other = 0
			games[two][list_2[other]] = '+'
			games[list_2[other]][two] = '-'
		print('\n'.join([''.join(l) for l in games]))


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, list(input())))
	answer = [['='] * n for i in range(n)]
	for i in range(n):
		answer[i][i] = 'X'
	twos = [idx for (idx, val) in enumerate(s) if val == 2]
	if len(twos) == 0:
		print('YES')
	elif len(twos) in [1, 2]:
		print('NO')
		continue
	else:
		print('YES')
		for i in range(1, len(twos)):
			answer[twos[i - 1]][twos[i]] = '+'
			answer[twos[i]][twos[i - 1]] = '-'
		answer[twos[-1]][twos[0]] = '+'
		answer[twos[0]][twos[-1]] = '-'
	for row in answer:
		print(''.join(row))


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_string():
	return list(map(str, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_print_int(x):
	sys.stdout.write(str(x) + '\n')

def get_print(x):
	sys.stdout.write(x + '\n')

def get_print_int_same(x):
	sys.stdout.write(str(x) + ' ')

def get_print_same(x):
	sys.stdout.write(x + ' ')
from sys import maxsize

def solve():
	for _ in range(get_int()):
		n = get_int()
		data = get_string()
		ans = [['='] * n for i in range(n)]
		for i in range(n):
			ans[i][i] = 'X'
		twos = []
		for i in range(n):
			if data[i] == '2':
				twos.append(i)
		flag = 0
		for i in range(len(twos)):
			ind1 = twos[i]
			f = 0
			for j in range(len(twos)):
				if i != j:
					ind2 = twos[j]
					if ans[ind1][ind2] == '=':
						ans[ind1][ind2] = '+'
						ans[ind2][ind1] = '-'
						f = 1
						break
			if f == 0:
				flag = 1
				break
		if flag == 1:
			get_print('NO')
		else:
			get_print('YES')
			for i in ans:
				get_print(''.join(map(str, i)))
solve()


for i in range(int(input())):
	n = int(input())
	s = input()
	c = p = f = 0
	for j in range(n):
		if s[j] == '2':
			if c == 0:
				f = j
			c = c + 1
			p = j
	if c > 2 or c == 0:
		print('YES')
		for j in range(n):
			for k in range(n):
				if j == k:
					print('X', end='')
				elif s[j] == '1' or s[k] == '1':
					print('=', end='')
				elif k == f and j == p:
					print('+', end='')
				elif k < j or (j == f and k == p):
					print('-', end='')
				else:
					print('+', end='')
			print()
	else:
		print('NO')


for x in range(int(input())):
	n = int(input())
	a = input()
	l = [['=' for j in range(n)] for i in range(n)]
	s = []
	for i in range(n):
		if a[i] == '2':
			s.append(i)
	if 0 < len(s) <= 2:
		print('NO')
	else:
		print('YES')
		m = len(s)
		for i in range(n):
			l[i][i] = 'X'
		for i in range(m):
			l[s[i]][s[(i + 1) % m]] = '+'
			l[s[(i + 1) % m]][s[i]] = '-'
		for i in l:
			print(''.join(i))


import sys
import getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
(yes, no) = ('YES', 'NO')
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def minus_one(arr):
	return [x - 1 for x in arr]

def minus_one_matrix(mrr):
	return [[x - 1 for x in row] for row in mrr]

def solve_(srr):
	res = [['=' for _ in srr] for _ in srr]
	for i in range(len(srr)):
		res[i][i] = 'X'
	if srr.count('2') == 1 or srr.count('2') == 2:
		return []
	arr = [i for (i, x) in enumerate(srr) if x == '2']
	brr = arr[1:] + arr[:1]
	for (a, b) in zip(arr, brr):
		res[a][b] = '+'
		res[b][a] = '-'
	return res
for case_num in range(int(input())):
	k = int(input())
	srr = input().strip()
	res = solve(srr)
	if res == []:
		print(no)
		continue
	print(yes)
	res = '\n'.join((''.join((str(x) for x in row)) for row in res))
	print(res)


T = int(input())
for _ in range(T):
	n = int(input())
	s = input()
	D = {i for i in range(n) if s[i] == '1'}
	W = [i for i in range(n) if s[i] == '2']
	if 0 < len(W) <= 2:
		print('NO')
	else:
		M = [[None] * n for _ in range(n)]
		for i in range(n):
			M[i][i] = 'X'
		for i in range(n):
			for j in range(i + 1, n):
				if i in D or j in D:
					M[i][j] = M[j][i] = '='
		w = len(W)
		for i in range(w):
			(first, second) = (W[i], W[(i + 1) % w])
			M[first][second] = '+'
			M[second][first] = '-'
		for i in range(n):
			for j in range(n):
				if M[i][j] is None:
					M[i][j] = '='
		print('YES')
		for m in M:
			print(''.join(m))


t = int(input())
while t:
	num = int(input())
	player = [int(p) for p in input()]
	count1 = 0
	for i in range(num):
		if player[i] == 1:
			count1 += 1
	if count1 == num:
		print('YES')
		matches = [['=' for i in range(num)] for j in range(num)]
		for i in range(num):
			matches[i][i] = 'X'
			print(''.join(matches[i]))
	elif num - count1 <= 2:
		print('NO')
	else:
		print('YES')
		matches = [['X' for i in range(num)] for j in range(num)]
		done = [False] * num
		for i in range(num):
			for j in range(i + 1, num):
				if player[i] == 2 and player[j] == 2:
					if done[i] == True:
						done[j] = True
						matches[i][j] = '-'
						matches[j][i] = '+'
					else:
						matches[i][j] = '+'
						matches[j][i] = '-'
						done[i] = True
				else:
					matches[i][j] = '='
					matches[j][i] = '='
			print(''.join(matches[i]))
	t -= 1


tc = int(input())
for t in range(tc):
	n = int(input())
	e = input()
	draws = e.count('1')
	win_ones = e.count('2')
	win_inds = []
	for i in range(len(e)):
		if e[i] == '2':
			win_inds.append(i)
	if win_ones <= 2 and win_ones != 0:
		print('NO')
	else:
		print('YES')
		ans = []
		for i in range(n):
			ans.append(['='] * n)
			ans[i][i] = 'X'
		for i in range(len(win_inds)):
			current_win_ind = win_inds[i]
			if i == len(win_inds) - 1:
				next_win_ind = win_inds[0]
			else:
				next_win_ind = win_inds[i + 1]
			ans[current_win_ind][next_win_ind] = '+'
			ans[next_win_ind][current_win_ind] = '-'
		for line in ans:
			print(''.join(line))


for _ in [0] * int(input()):
	n = int(input())
	s = input()
	if s.count('2') in [1, 2]:
		print('NO')
		continue
	a = [list('=' * i + 'X' + '=' * (n - i - 1)) for i in range(n)]
	b = [i for i in range(n) if s[i] == '2']
	k = len(b)
	for i in range(k):
		(a[b[i]][b[(i + 1) % k]], a[b[(i + 1) % k]][b[i]]) = ('+', '-')
	print('YES')
	for i in a:
		print(''.join(i))


import sys
input = sys.stdin.readline

def solve(n, s):
	A = [['X'] * n for _ in range(n)]
	one = []
	two = []
	for (i, x) in enumerate(s):
		if x == '1':
			one.append(i)
		elif x == '2':
			two.append(i)
	for i in one:
		for r in range(n):
			if r == i:
				continue
			A[r][i] = '='
		for c in range(n):
			if c == i:
				continue
			A[i][c] = '='

	def dfs(i):
		if i == len(two):
			return True
		r = two[i]
		for c in range(n):
			if c == r:
				continue
			if A[r][c] == 'X' and (A[c][r] == 'X' or A[c][r] == '-'):
				A[r][c] = '+'
				A[c][r] = '-'
				if dfs(i + 1):
					return True
				A[r][c] = 'X'
				A[c][r] = 'X'
		return False
	if not dfs(0):
		return (False, [])
	for r in range(n):
		for c in range(n):
			if r != c and A[r][c] == 'X':
				A[r][c] = '='
	return (True, A)
T = int(input())
for _ in range(T):
	n = int(input())
	s = input().strip()
	(ans, A) = solve(n, s)
	if ans:
		print('YES')
		for row in A:
			print(''.join(row))
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input().rstrip()
	ans = [[0 for i in range(n)] for i in range(n)]
	cnt = 0
	for i in range(n):
		for j in range(n):
			if i == j:
				ans[i][j] = 'X'
				continue
			if s[i] == '1' and s[j] == '1':
				ans[i][j] = '='
			elif s[i] == '1' and s[j] == '2':
				ans[i][j] = '='
			elif s[i] == '2' and s[j] == '1':
				ans[i][j] = '='
			else:
				cnt += 1
	if cnt > 0:
		if cnt % 2 == 0:
			if cnt == 2:
				print('NO')
				continue
			else:
				first = n
				last = 0
				for i in range(n):
					for j in range(n):
						if s[i] == '2' and s[j] == '2':
							if i < j:
								first = min(first, i)
								last = max(last, j)
								ans[i][j] = '+'
								ans[j][i] = '-'
				ans[first][last] = '-'
				ans[last][first] = '+'
		elif cnt == 1:
			print('NO')
			continue
		else:
			first = n
			last = 0
			for i in range(n):
				for j in range(n):
					if s[i] == '2' and s[j] == '2':
						if i < j:
							first = min(first, i)
							last = max(last, j)
							ans[i][j] = '+'
							ans[j][i] = '-'
			ans[first][last] = '-'
			ans[last][first] = '+'
	flag = True
	for i in range(n):
		if s[i] == '2' and '+' not in ans[i]:
			flag = False
			break
	if not flag:
		print('NO')
		continue
	print('YES')
	for i in range(n):
		print(''.join(ans[i]))


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	if a.count('2') == 1 or a.count('2') == 2:
		print('NO')
		continue
	else:
		print('YES')
		ans = [['' for i in range(n)] for j in range(n)]
		for i in range(n):
			ans[i][i] = 'X'
		for i in range(n):
			if a[i] == '1':
				for j in range(n):
					if i != j:
						ans[i][j] = '='
						ans[j][i] = '='
		tobe = []
		for i in range(n):
			if a[i] == '2':
				tobe.append(i)
		for i in range(len(tobe) - 1):
			ans[tobe[i]][tobe[i + 1]] = '+'
			ans[tobe[i + 1]][tobe[i]] = '-'
		if len(tobe) > 2:
			ans[tobe[-1]][tobe[0]] = '+'
			ans[tobe[0]][tobe[-1]] = '-'
		for i in range(n):
			for j in range(n):
				if ans[i][j] == '':
					ans[i][j] = '='
		for i in range(n):
			for j in range(n):
				print(ans[i][j], end='')
			print()


def solve():
	n = int(input())
	s = [int(x) for x in list(input())]
	grid = [['=' for x in range(n)] for y in range(n)]
	for i in range(n):
		grid[i][i] = 'X'
		if s[i] == 1:
			continue
		ok = False
		for j in range(n):
			if i == j or s[j] == 1 or grid[i][j] != '=':
				continue
			grid[i][j] = '+'
			grid[j][i] = '-'
			ok = True
			break
		if not ok:
			print('NO')
			return
	print('YES')
	for row in grid:
		print(''.join(row))
t = int(input())
for k in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	players = input()
	b = players.count('2')
	sec = []
	aaaa = [str(x) for x in players]
	for (index, nums) in enumerate(aaaa):
		if nums == '2':
			sec.append(index)
	if b == 1 or b == 2:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			iplayer = []
			if players[i] == '1':
				for j in range(n):
					if j == i:
						iplayer.append('X')
					else:
						iplayer.append('=')
			if players[i] == '2':
				for j in range(n):
					if i == j:
						iplayer.append('X')
					elif players[j] == '1':
						iplayer.append('=')
					elif players[j] == '2':
						if j < i:
							iplayer.append('-')
						elif j > i:
							iplayer.append('+')
				if b > 0:
					if i == sec[0]:
						iplayer[sec[-1]] = '-'
					if i == sec[-1]:
						iplayer[sec[0]] = '+'
			an = ''.join(iplayer)
			print(an)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	ans = []
	for k in range(n):
		ans.append([])
		for j in range(n):
			ans[k].append('=')
	for p in range(n):
		ans[p][p] = 'X'
	if s.count('2') == 0:
		print('YES')
		for aboba in range(n):
			print(''.join(ans[aboba]))
	elif s.count('2') < 3:
		print('NO')
	else:
		boba = []
		for ab in range(n):
			if s[ab] == '2':
				boba.append(ab)
		for a in range(1, len(boba)):
			ans[boba[a - 1]][boba[a]] = '+'
			ans[boba[a]][boba[a - 1]] = '-'
		ans[boba[0]][boba[-1]] = '-'
		ans[boba[-1]][boba[0]] = '+'
		print('YES')
		for aboba in range(n):
			print(''.join(ans[aboba]))


for _ in range(int(input())):
	size = int(input())
	st = str(input())
	sec_t = 0
	arr = []
	matrix = []
	can_be_done = 1
	for ind in range(size):
		line = []
		for ind1 in range(size):
			line.append('')
		matrix.append(line)
	for char in st:
		if char == '2':
			sec_t += 1
			arr.append(int(char))
	if 3 > sec_t > 0:
		print('NO')
		can_be_done = 0
	else:
		print('YES')
		for i in range(size):
			if st[i] == '2':
				won = 0
			for y in range(i, size):
				if i == y:
					matrix[i][y] = 'X'
				elif st[i] == '2':
					if st[y] == '1':
						matrix[i][y] = '='
						matrix[y][i] = '='
					elif st[y] == '2' and won == 1:
						matrix[i][y] = '-'
						matrix[y][i] = '+'
					else:
						matrix[i][y] = '+'
						matrix[y][i] = '-'
						won += 1
				else:
					matrix[i][y] = '='
					matrix[y][i] = '='
	if can_be_done:
		for ind in range(len(matrix)):
			for ind1 in range(len(matrix)):
				print(matrix[ind][ind1], end='')
			print()


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	twos = 0
	twos_list = []
	ones = 0
	for i in range(n):
		if s[i] == '1':
			ones += 1
		elif s[i] == '2':
			twos += 1
			twos_list.append(i)
	if twos == 1 or twos == 2:
		print('NO')
	elif len(twos_list) > 1:
		ans = []
		for i in range(n):
			l = ['0' for j in range(n)]
			ans.append(l)
		last = 0
		for i in range(len(twos_list) - 1):
			ans[twos_list[i]][twos_list[i + 1]] = '+'
			ans[twos_list[i + 1]][twos_list[i]] = '-'
			last = twos_list[i + 1]
		ans[last][twos_list[0]] = '+'
		ans[twos_list[0]][last] = '-'
		for i in range(n):
			for j in range(n):
				if ans[i][j] == '0':
					if i == j:
						ans[i][j] = 'X'
					else:
						ans[i][j] = '='
		print('YES')
		for i in range(n):
			for j in range(n):
				print(ans[i][j], end='')
			print()
	else:
		ans = []
		for i in range(n):
			l = ['0' for j in range(n)]
			ans.append(l)
		for i in range(n):
			for j in range(n):
				if ans[i][j] == '0':
					if i == j:
						ans[i][j] = 'X'
					else:
						ans[i][j] = '='
		print('YES')
		for i in range(n):
			for j in range(n):
				print(ans[i][j], end='')
			print()


t = int(input())
YES = 'YES'
NO = 'NO'

def calc(n, m, k):
	if n == 1:
		return m == 0 and k >= 2
	nc2 = n * (n - 1) // 2
	if m > nc2:
		return False
	if m == nc2:
		return k >= 3
	if m >= n - 1:
		return k >= 4
	return False
for _ in range(t):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	ys = []
	for (i, ch) in enumerate(s):
		if ch == '1':
			x += 1
		else:
			y += 1
			ys.append(i)
	if y == 1 or y == 2:
		print(NO)
		continue
	else:
		print(YES)
	matrix = [['X' if i == j else '=' for i in range(n)] for j in range(n)]
	if y > 2:
		for i in range(y):
			j = (i + 1) % y
			(yi, yj) = (ys[i], ys[j])
			matrix[yi][yj] = '+'
			matrix[yj][yi] = '-'
	for row in matrix:
		print(''.join(row))


def solve(n, s):
	M = [['='] * n for i in range(n)]
	for i in range(n):
		M[i][i] = 'X'
	c = 0
	A = []
	for i in range(n):
		if int(s[i]) == 2:
			c += 1
			A.append(i)
	if c == 1 or c == 2:
		print('NO')
		return
	if c != 0:
		m = len(A)
		for x in range(m - 1):
			i = A[x]
			j = A[x + 1]
			M[i][j] = '+'
			M[j][i] = '-'
		i = A[m - 1]
		j = A[0]
		M[i][j] = '+'
		M[j][i] = '-'
	print('YES')
	for i in M:
		print(''.join(i))
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	solve(n, s)


t = int(input())

def find_next_win(s, idx):
	first_i = s.find('2')
	for i in range(len(s)):
		if s[i] == '2' and i > idx:
			return i
	return first_i

def find_prev_idx(s, idx):
	last_i = s.rfind('2')
	for i in range(len(s)):
		if s[::-1][i] == '2' and i > len(s) - idx - 1:
			return len(s) - i - 1
	return last_i
for i in range(t):
	n = int(input())
	s = input()
	draw_count = s.count('1')
	win_count = s.count('2')
	if win_count == 1 or win_count == 2:
		print('NO')
	else:
		print('YES')
		for idx in range(n):
			if s[idx] == '1':
				option = '=' * idx + 'X' + '=' * (n - idx - 1)
				print(option)
			else:
				option = '=' * n
				option = option[:idx] + 'X' + option[idx + 1:]
				win_idx = find_next_win(s, idx)
				option = option[:win_idx] + '+' + option[win_idx + 1:]
				lose_idx = find_prev_idx(s, idx)
				option = option[:lose_idx] + '-' + option[lose_idx + 1:]
				print(option)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	v = []
	for i in range(n):
		if s[i] == '2':
			v.append(i)
	if s.count('2') in (1, 2):
		print('NO')
	else:
		print('YES')
		a = []
		for i in range(n):
			l = ['='] * n
			l[i] = 'X'
			a.append(l)
		for i in range(len(v)):
			for j in range(i + 1, len(v)):
				if i != len(v) - 1:
					a[v[i]][v[j]] = '+'
					a[v[j]][v[i]] = '-'
		if len(v) != 0:
			a[v[0]][v[-1]] = '-'
			a[v[-1]][v[0]] = '+'
		for i in a:
			g = ''
			for j in i:
				g += j
			print(g)


from collections import Counter

def NO(s):
	counter = Counter(s)
	if counter['2'] in (1, 2):
		return True
	return False

def alg(s: str):
	n = len(s)
	ar = [['=' for i in range(n)] for i in range(n)]
	for i in range(n):
		ar[i][i] = 'X'
	players_no_loose = [idx for (idx, p) in enumerate(s) if p == '1']
	players_win = [idx for (idx, p) in enumerate(s) if p == '2']
	if len(players_win) > 0:
		for (p_prev, p_cur) in zip(players_win[:-1], players_win[1:]):
			ar[p_prev][p_cur] = '+'
			ar[p_cur][p_prev] = '-'
		(p_cur, p_prev) = (players_win[0], players_win[-1])
		ar[p_prev][p_cur] = '+'
		ar[p_cur][p_prev] = '-'
	return ar

def print_ans(ar):
	print('YES')
	for row in ar:
		print(''.join(row))
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if NO(s):
		print('NO')
	else:
		print_ans(alg(s))


t = int(input())
for ii in range(t):
	n = int(input())
	s = input().rstrip()
	impos = 0
	a = [[0] * n for i in range(n)]
	for i in range(n):
		flag = 0
		for j in range(n):
			if i == j:
				a[i][j] = 'X'
			elif s[i] == '1':
				a[i][j] = '='
			else:
				if a[i][j] == '-':
					continue
				if s[j] == '2' and (j < i and a[j].count('=') > 0 and (a[j][i] != '+') or (j > i and a[j].count(0) > 2 and (a[j][i] != '-'))):
					a[j][i] = '-'
					a[i][j] = '+'
					flag = 1
					for k in range(j + 1, n):
						if a[i][k] == 0:
							a[i][k] = '='
						if i == k:
							a[i][k] = 'X'
					break
				else:
					a[i][j] = '='
		if s[i] == '2' and flag == 0:
			impos = 1
			break
	if impos:
		print('NO')
	else:
		print('YES')
		for i in a:
			print(''.join(i))


for _ in range(int(input())):
	(count, hope) = (int(input()), input())
	win = hope.count('2')
	draw = count - win
	if 0 < win < 3:
		print('NO')
	else:
		print('YES')
		list_match = [[0 for j in range(count)] for i in range(count)]
		for i in range(count):
			for j in range(count):
				if i == j:
					list_match[i][j] = 'X'
				elif hope[i] == '1' or hope[j] == '1':
					list_match[i][j] = '='
					list_match[j][i] = '='
				elif '+' not in list_match[i] and list_match[i][j] == 0:
					list_match[i][j] = '+'
					list_match[j][i] = '-'
				elif '+' not in list_match[j] and list_match[j][i] == 0:
					list_match[i][j] = '-'
					list_match[j][i] = '+'
				elif list_match[i][j] == 0:
					list_match[i][j] = '+'
					list_match[j][i] = '-'
			print(''.join(list_match[i]))


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
import math
from bisect import *
from heapq import *
from collections import defaultdict as dd
from collections import OrderedDict as odict
from collections import Counter as cc
from collections import deque
from itertools import groupby
sys.setrecursionlimit(20 * 20 * 20 * 20 + 10)

def solve():
	n = takein()
	string = takesr()
	mat = [[''] * n for i in range(n)]
	if 1 <= string.count('2') <= 2:
		print('NO')
		return
	print('YES')
	for i in range(n):
		if string[i] == '2':
			ans = True
			for j in range(n):
				if i != j and mat[i][j] == '+':
					ans = False
					break
		for j in range(n):
			if i == j:
				mat[i][j] = 'X'
			elif string[i] == '1' or string[j] == '1':
				mat[i][j] = '='
			elif mat[i][j] == '':
				if ans:
					ans = False
					mat[i][j] = '+'
					mat[j][i] = '-'
				else:
					mat[i][j] = '-'
					mat[j][i] = '+'
	for i in range(n):
		for j in range(n):
			print(mat[i][j], end='')
		print()

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = takein()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def takein():
	return int(sys.stdin.readline().rstrip('\r\n'))

def takesr():
	return sys.stdin.readline().rstrip('\r\n')

def takeiar():
	return list(map(int, sys.stdin.readline().rstrip('\r\n').split()))

def takesar():
	return list(map(str, sys.stdin.readline().rstrip('\r\n').split()))

def takeivr():
	return map(int, sys.stdin.readline().rstrip('\r\n').split())

def takesvr():
	return map(str, sys.stdin.readline().rstrip('\r\n').split())

def ispalindrome(s):
	return s == s[::-1]

def invert(bit_s):
	temp = int(bit_s, 2)
	inverse_s = temp ^ 2 ** (len(bit_s) + 1) - 1
	rslt = bin(inverse_s)[3:]
	return str(rslt)

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	if 0 < s.count('2') <= 2:
		print('NO')
	else:
		print('YES')
		ans = [['='] * n for i in range(n)]
		for i in range(n):
			f = 1
			for j in range(n):
				if i == j:
					ans[i][j] = 'X'
				elif s[i] == '2' and s[j] == '2' and (f == 1) and (ans[i][j] == '='):
					ans[i][j] = '+'
					ans[j][i] = '-'
					f = 0
		for j in ans:
			print(''.join(map(str, j)))


import time
from collections import deque

def inpt():
	return int(input())

def inpl():
	return list(map(int, input().split()))

def inpm():
	return map(int, input().split())

def solve():
	n = inpt()
	s = input()
	if 1 <= s.count('2') <= 2:
		print('NO')
		return
	ans = [['=' for i in range(n)] for i in range(n)]
	for i in range(n):
		ans[i][i] = 'X'
	if s.count('2') == 0:
		print('YES')
		for i in range(n):
			print(''.join(ans[i]))
		return
	count = -1
	first = 0
	for i in range(n):
		if s[i] == '2':
			if count == -1:
				count = i
				first = i
			else:
				ans[count][i] = '+'
				ans[i][count] = '-'
				count = i
	ans[first][count] = '-'
	ans[count][first] = '+'
	print('YES')
	for i in range(n):
		print(''.join(ans[i]))

def main():
	m = 10 ** 9 + 7
	t = int(input())
	while t:
		t -= 1
		solve()
main()


import math
import sys
from math import cos, pi, ceil, pi, tan, floor, gcd, sqrt, log2, factorial, log10
from collections import Counter
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase
from statistics import mean, median, mode
from bisect import *
alpha = ascii_lowercase
beta = ascii_uppercase

def nextPowerOf2(n):
	p = 1
	if n and (not n & n - 1):
		return n
	while p < n:
		p <<= 1
	return p

def get_Divisors(n):
	arr = []
	i = 1
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				arr.append(i)
			else:
				arr.append(i)
				arr.append(n // i)
		i = i + 1
	return arr

def isprime(n):
	if n == 1:
		return 0
	i = 2
	while i * i <= n:
		if n % i == 0:
			return 0
		i += 1
	return 1

def Sieve(n):
	prime = [True for i in range(n + 1)]
	prime[0] = False
	prime[1] = False
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def create_matrix(n, m):
	mat = [[] for i in range(n)]
	for i in range(n):
		for j in range(m):
			mat[i].append(0)
	return mat

def main():
	for ttt in range(int(input())):
		n = int(input())
		s = input()
		s = [int(s[i]) for i in range(n)]
		mat = create_matrix(n, n)
		for i in range(n):
			mat[i][i] = 'X'
		for i in range(n):
			if s[i] == 1:
				for j in range(n):
					if mat[i][j] == 0:
						mat[i][j] = '='
						mat[j][i] = '='
		for i in range(n):
			if s[i] == 1:
				pass
			else:
				flag = 0
				for j in range(n):
					if mat[i][j] == 0:
						if flag == 0:
							mat[i][j] = '+'
							mat[j][i] = '-'
							flag = 1
						else:
							mat[i][j] = '-'
							mat[j][i] = '+'
		for i in range(n):
			if s[i] == 1:
				c = 0
				for j in range(n):
					if mat[i][j] == '-':
						c += 1
				if c > 0:
					print('NO')
					break
			else:
				c = 0
				for j in range(n):
					if mat[i][j] == '+':
						c += 1
				if c < 1:
					print('NO')
					break
		else:
			print('YES')
			for i in mat:
				print(''.join(i))
main()


from collections import Counter, deque
from math import *
mod = 1000000007

def solve():
	n = int(input())
	s = input()
	x = s.count('2')
	if s.count('2') <= 2:
		if x != 0:
			print('NO')
			return
	d = {i: [-1] * n for i in range(n)}
	for i in range(n):
		if s[i] == '1':
			for j in range(n):
				if i == j:
					d[i][j] = 'X'
				else:
					d[i][j] = '='
					d[j][i] = '='
	for i in range(n):
		if s[i] != '1':
			cur = 0
			for j in range(n):
				if i == j:
					d[i][j] = 'X'
				elif cur == 0:
					if d[i][j] == -1:
						d[i][j] = '+'
						d[j][i] = '-'
						cur += 1
				elif d[i][j] == -1:
					d[i][j] = '-'
					d[j][i] = '+'
	print('YES')
	for i in range(n):
		print(''.join(d[i]))
t = int(input())
for _ in range(t):
	solve()


z = int(input())
for _ in range(z):
	n = int(input())
	s = input()
	l = []
	for i in range(len(s)):
		x = []
		for j in range(len(s)):
			if i == j:
				x.append('X')
			else:
				x.append('=')
		l.append(x)
	k = 0
	for i in range(len(s)):
		if s[i] == '1':
			continue
		flag = True
		for j in range(len(s)):
			if i == j or s[j] == '1' or l[j][i] == '+':
				continue
			else:
				l[i][j] = '+'
				l[j][i] = '-'
				flag = False
				break
		if flag:
			print('NO')
			k = 1
			break
	if k == 0:
		print('YES')
		for i in range(len(s)):
			for j in range(len(s)):
				print(l[i][j], end='')
			print()


t = int(input())
for aslkdjaskdj in range(t):
	n = int(input())
	z = input()
	c1 = z.count('1')
	l = []
	for i in range(n):
		l.append(['='] * n)
	for i in range(n):
		l[i][i] = 'X'
	if n - c1 == 0:
		print('YES')
		for i in l:
			print(''.join(i))
	elif n - c1 > 2:
		l1 = []
		for i in range(n):
			if z[i] == '2':
				l1.append(i)
		for i in range(len(l1)):
			try:
				l[l1[i]][l1[i + 1]] = '+'
				l[l1[i + 1]][l1[i]] = '-'
			except:
				l[l1[i]][l1[0]] = '+'
				l[l1[0]][l1[i]] = '-'
		print('YES')
		for i in l:
			print(''.join(i))
	else:
		print('NO')


import os, sys
from io import BytesIO, IOBase

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class dict(dict):

	def __missing__(self, key):
		return 0
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda dtype: [dtype(x) for x in input().split()]
inp_2d = lambda dtype, n: [dtype(input()) for _ in range(n)]
inp_2ds = lambda dtype, n: [inp(dtype) for _ in range(n)]
inp_enu = lambda dtype: [(i, x) for (i, x) in enumerate(inp(dtype))]
inp_enus = lambda dtype, n: [[i] + inp(dtype) for i in range(n)]
ceil1 = lambda a, b: (a + b - 1) // b
for _ in range(int(input())):
	(n, s) = (int(input()), input())
	if s.count('2') in [1, 2]:
		print('NO')
		continue
	mem = [-1] * n
	try:
		lst = s.index('2')
		for i in range(n - 1, -1, -1):
			if s[i] == '2':
				mem[i] = lst
				lst = i
	except:
		pass
	print('YES')
	ans = [['='] * n for _ in range(n)]
	for i in range(n):
		for j in range(n):
			if i == j:
				ans[i][j] = 'X'
			elif s[i] == '2' and s[j] == '2':
				if mem[i] == j:
					(ans[i][j], ans[j][i]) = ('+', '-')
	[print(*x, sep='') for x in ans]


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	s = stdin.readline()[:-1]
	ans = [['='] * n for i in range(n)]
	for i in range(n):
		ans[i][i] = 'X'
	bs = []
	for i in range(n):
		if s[i] == '2':
			bs.append(i)
	if len(bs) == 1 or len(bs) == 2:
		print('NO')
		continue
	print('YES')
	for i in range(len(bs)):
		st = bs[i]
		tp = bs[(i + 1) % len(bs)]
		ans[st][tp] = '+'
		ans[tp][st] = '-'
	for i in range(n):
		print(''.join(ans[i]))


for case in range(int(input())):
	n = int(input())
	s = list(input())
	firstType = list()
	secondType = list()
	ans = list(([0] * n for i in range(n)))
	flag = 1
	for i in range(n):
		if s[i] == '1':
			firstType.append(i)
		else:
			secondType.append(i)
	for i in firstType:
		for j in range(n):
			if i == j:
				ans[i][j] = 'X'
			else:
				ans[i][j] = '='
				ans[j][i] = '='
	for i in secondType:
		f = 0
		for j in range(n):
			if ans[i][j] == '+':
				f = j + 1
				break
			elif i == j:
				ans[i][j] = 'X'
			elif ans[i][j] == 0:
				ans[i][j] = '+'
				ans[j][i] = '-'
				f = j + 1
				break
		if f != 0:
			for j in range(f, n):
				if i == j:
					ans[i][j] = 'X'
				elif ans[i][j] == 0:
					ans[i][j] = '-'
					ans[j][i] = '+'
		else:
			flag = 0
	for i in range(n):
		if flag == 0:
			break
		for j in range(n):
			if ans[i][j] == '0':
				flag = 0
				break
	if flag:
		print('YES')
		for i in ans:
			print(*i, sep='')
	else:
		print('NO')


def lastIndex(arr, x):
	for i in reversed(range(len(arr))):
		if arr[i] == x:
			return i

def solve(n, exp):
	if exp.count(2) in range(1, 3):
		print('NO')
		return
	else:
		board = [['=' for i in range(n)] for i in range(n)]
		for i in range(n):
			board[i][i] = 'X'
		if exp.count(2) != 0:
			firstIndexOf2 = exp.index(2)
			lastIndexOf2 = lastIndex(exp, 2)
			for i in range(firstIndexOf2, lastIndexOf2):
				if exp[i] == 2:
					for j in range(i + 1, lastIndexOf2 + 1):
						if exp[j] == 2:
							board[i][j] = '+'
							board[j][i] = '-'
			board[lastIndexOf2][firstIndexOf2] = '+'
			board[firstIndexOf2][lastIndexOf2] = '-'
		print('YES')
		for i in range(n):
			print(''.join(board[i]))
tcs = int(input())
for i in range(tcs):
	n = int(input())
	e = input()
	exp = list(map(int, e))
	solve(n, exp)


import collections
import os
import sys
from datetime import date
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7
import math
import statistics
from bisect import bisect_right
for __ in range(int(input())):
	n = int(input())
	s = input()
	ans = [[0 for i in range(n)] for j in range(n)]
	l = []
	for i in range(n):
		if s[i] == '2':
			l.append(i)
	if len(l) <= 2 and len(l) > 0:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			for j in range(n):
				if i == j:
					ans[i][j] = 'X'
				elif s[i] == '1':
					ans[i][j] = '='
				else:
					ans[i][j] = '='
		for i in range(len(l)):
			if i == len(l) - 1:
				ans[l[i]][l[0]] = '+'
				ans[l[0]][l[i]] = '-'
			else:
				ans[l[i]][l[i + 1]] = '+'
				ans[l[i + 1]][l[i]] = '-'
		for c in ans:
			print(''.join(map(str, c)))


from itertools import compress

def main():
	in_n = int(input())
	for _ in range(in_n):
		inlines = []
		for _ in range(2):
			inlines.append(input().rstrip())
		n = int(inlines[0])
		row = [int(ch) - 1 for ch in inlines[1]]
		if sum(row) < 3 and sum(row) > 0:
			print('NO')
		else:
			print('YES')
			matrix = []
			winners = list(compress(range(len(row)), row))
			for (i, player) in enumerate(row):
				plstr = list('=' * n)
				plstr[i] = 'X'
				matrix.append(plstr)
			if sum(row) > 0:
				for (i, winner) in enumerate(winners):
					if i == len(winners) - 1:
						loser = winners[0]
					else:
						loser = winners[i + 1]
					matrix[loser][winner] = '-'
					matrix[winner][loser] = '+'
			for m in matrix:
				empt = ''
				print(empt.join(m))
main()


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(input())
	s = input()
	ans = [['=' for j in range(n)] for i in range(n)]
	t = 0
	for i in range(n):
		ans[i][i] = 'X'
		if s[i] == '2':
			t += 1
	for i in range(n):
		if s[i] == '2':
			f = -1
			for j in range(n):
				if s[j] != '1' and j != i:
					ans[i][j] = '+'
					ans[j][i] = '-'
					f = j
					break
			for k in range(n):
				if ans[f][k] != '-' and s[k] != '1' and (k != f):
					ans[f][k] = '+'
					ans[k][f] = '-'
			for j in range(n):
				if s[j] != '1' and j != i and (ans[i][j] != '+'):
					ans[i][j] = '-'
					ans[j][i] = '+'
			break
	if t == 1 or t == 2:
		print('NO')
	else:
		print('YES')
		for i in ans:
			a = ''.join(i)
			print(a)


from collections import Counter, defaultdict
from sys import stdin, stdout
import io, os, sys
input = stdin.readline

def mapinput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))

def intinput():
	return int(stdin.readline())

def strinput():
	return input().strip()

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	ans = []
	for p in range(n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def writ(ss):
	stdout.write(str(ss) + '\n')
for test in range(int(input())):

	def solve():
		n = intinput()
		s = strinput()
		cc = Counter(s)
		if cc['2'] == 1 or cc['2'] == 2:
			print('NO')
			return
		ans = [['X'] * n for i in range(n)]
		for i in range(n):
			flag = 0
			for j in range(i + 1, n):
				if s[i] == '1' or s[j] == '1':
					ans[i][j] = '='
					ans[j][i] = '='
				elif flag == 0:
					ans[i][j] = '+'
					ans[j][i] = '-'
					flag = 1
				else:
					ans[i][j] = '-'
					ans[j][i] = '+'
		print('YES')
		for i in range(n):
			print(''.join(ans[i]))
	solve()


def find(str, ch):
	for (i, ltr) in enumerate(str):
		if ltr == ch:
			yield i
test = int(input())
for i in range(test):
	n = int(input())
	s = input()
	if s.count('2') <= 2 and s.count('2') > 0:
		print('NO')
	else:
		print('YES')
		lol = list(find(s, '2'))
		lol = lol[-1:] + lol[:-1]
		matrix = [['=' for x in range(n)] for y in range(n)]
		for sth in range(n):
			if s[sth] == '2':
				matrix[sth][int(lol[0])] = '-'
				matrix[int(lol[0])][sth] = '+'
				lol.remove(lol[0])
			matrix[sth][sth] = 'X'
		for i in range(len(matrix)):
			print(''.join((str(i) for i in matrix[i])))


for _ in range(int(input())):
	a = int(input())
	b = list(input())
	g = []
	for i in range(a):
		temp = []
		for j in range(a):
			if i == j:
				temp.append('X')
			else:
				temp.append(' ')
		g.append(temp)
	for j in range(a):
		if b[j] == '1':
			for k in range(a):
				if k != j:
					g[j][k] = g[k][j] = '='
	for j in range(a):
		if b[j] == '2':
			fl = False
			for p in range(a):
				if g[j][p] == ' ':
					if not fl:
						g[j][p] = '+'
						g[p][j] = '-'
						fl = True
	dl = False
	for i in range(a):
		if b[i] == '2' and '+' not in g[i]:
			dl = True
		for j in range(a):
			if g[i][j] == ' ':
				g[i][j] = '='
	if dl:
		print('NO')
	else:
		print('YES')
		for i in g:
			print(''.join(i))


def unpack(tabl, n):
	for i in range(n):
		print(*tabl[i], sep='')
for _ in range(int(input())):
	n = int(input())
	s = input()
	tabl = []
	for i in range(n):
		tabl.append([])
		for j in range(n):
			if i == j:
				tabl[i].append('X')
			elif s[i] == '1' or s[j] == '1':
				tabl[i].append('=')
			else:
				tabl[i].append('0')
	ans = 1
	for i in range(n):
		if s[i] == '2':
			ok = 0
			for j in range(n):
				if tabl[i][j] == '0':
					tabl[i][j] = '+'
					tabl[j][i] = '-'
					ok = 1
					break
			if ok == 0:
				ans = 0
				print('NO')
				break
	for i in range(n):
		for j in range(n):
			if tabl[i][j] == '0':
				tabl[i][j] = '='
				tabl[j][i] = '='
	if ans == 1:
		print('YES')
		unpack(tabl, n)


import sys
MOD = 1000000007

def inp():
	return sys.stdin.readline().strip()

def ii():
	return int(inp())

def iis():
	return [int(i) for i in inp().split()]

def solve():
	n = ii()
	s = inp()
	twoIdxs = [i for (i, el) in enumerate(s) if el == '2']
	numTwos = len(twoIdxs)
	if numTwos > 0 and numTwos < 3:
		print('NO')
		return
	print('YES')
	grid = [['.' for _ in range(n)] for _ in range(n)]
	for (i, num) in enumerate(s):
		if num == '1':
			for j in range(n):
				grid[i][j] = '='
				grid[j][i] = '='
	for (i, twoIdxI) in enumerate(twoIdxs):
		for (j, twoIdxJ) in enumerate(twoIdxs):
			if i != j and grid[twoIdxI][twoIdxJ] == '.':
				grid[twoIdxI][twoIdxJ] = '='
		if i == numTwos - 1:
			grid[twoIdxs[-1]][twoIdxs[0]] = '+'
			grid[twoIdxs[0]][twoIdxs[-1]] = '-'
		else:
			grid[twoIdxI][twoIdxs[i + 1]] = '+'
			grid[twoIdxs[i + 1]][twoIdxI] = '-'
	for i in range(n):
		grid[i][i] = 'X'
	print('\n'.join([''.join(row) for row in grid]))
t = ii()
for _ in range(t):
	solve()


def sol():
	n = int(input())
	s = input()
	matrix = [['='] * n for i in range(n)]
	wygrac = []
	for i in range(n):
		if s[i] == '1':
			matrix[i][i] = 'X'
		else:
			matrix[i][i] = 'X'
			wygrac.append(i)
	for ind in wygrac:
		stan = 0
		for u in range(n):
			if u != ind and matrix[u][ind] == '=' and (s[u] != '1'):
				stan = 1
				matrix[u][ind] = '-'
				matrix[ind][u] = '+'
				break
		if not stan:
			print('NO')
			return
	print('YES')
	for i in range(n):
		print(''.join(matrix[i]))

def main():
	for i in range(int(input())):
		sol()
main()


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	(s1, s2) = ([], [])
	for i in range(n):
		if s[i] == '1':
			s1.append(i)
		elif s[i] == '2':
			s2.append(i)
	if len(s2) == 1 or len(s2) == 2:
		print('NO')
	else:
		print('YES')
		mat = [['=' for i in range(n)] for j in range(n)]
		for i in s1:
			for j in range(n):
				mat[i][j] = '='
				mat[j][i] = '='
		for i in range(len(s2) - 1):
			mat[s2[i]][s2[i + 1]] = '+'
			mat[s2[i + 1]][s2[i]] = '-'
		if len(s2) > 0:
			mat[s2[-1]][s2[0]] = '+'
			mat[s2[0]][s2[-1]] = '-'
		for i in range(n):
			mat[i][i] = 'X'
		for l in mat:
			print(''.join(l))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	n_twos = 0
	two_indices = []
	for i in range(n):
		if s[i] == '2':
			n_twos += 1
			two_indices.append(i)
	if n_twos == 1 or n_twos == 2:
		print('NO')
		continue
	print('YES')
	m = [['='] * n for _ in range(n)]
	for i in range(n):
		m[i][i] = 'X'
	for i in range(len(two_indices)):
		m[two_indices[i]][two_indices[(i + 1) % len(two_indices)]] = '+'
		m[two_indices[(i + 1) % len(two_indices)]][two_indices[i]] = '-'
	for l in m:
		print(''.join(l))


t = int(input())
for w in range(t):
	n = int(input())
	Wishes = input()
	N = [['=' for i in range(n)] for i in range(n)]
	for i in range(n):
		N[i][i] = 'X'
	Winners = []
	winnersCount = 0
	for i in range(n):
		if Wishes[i] != '1':
			winnersCount += 1
			Winners.append(i)
	if winnersCount == 1 or winnersCount == 2:
		print('NO')
	else:
		print('YES')
		for i in range(winnersCount):
			N[Winners[i - 1]][Winners[i]] = '+'
			N[Winners[i]][Winners[i - 1]] = '-'
		for i in range(n):
			for j in range(n):
				print(N[i][j], end='')
			print('')


T = int(input())
for t in range(T):
	n = int(input())
	exp = list(input())
	res = []
	annoy = [x for x in range(n) if exp[x] == '2']
	if annoy:
		first = annoy[0]
		last = annoy[-1]
		if first == last or len(annoy) < 3:
			print('NO')
			continue
	else:
		first = -1
		last = -1
	lastRow = []
	for p in range(n):
		if exp[p] == '1':
			row = ['='] * n
			row[p] = 'X'
		elif p == first:
			row = ['+' if x in annoy else '=' for x in range(n)]
			row[p] = 'X'
			row[last] = '-'
		elif p == last:
			row = ['-' if x in annoy else '=' for x in range(n)]
			row[p] = 'X'
			row[first] = '+'
		else:
			row = ['='] * n
			row[p] = 'X'
			row[last] = '+'
			row[first] = '-'
		res.append(row)
	print('YES')
	[print(''.join(x)) for x in res]


import sys
import math

def inpu():
	return sys.stdin.readline()
T = int(input())
for t in range(T):
	n = int(input())
	a = input()
	done = False
	on = a.count('1')
	tw = n - on
	if tw == 0:
		print('YES')
		for i in range(n):
			print('=' * i + 'X' + '=' * (n - i - 1))
		continue
	elif tw <= 2:
		print('NO')
		continue
	ss = set()
	i0 = a.index('2')
	i00 = i0
	for i in range(i0 + 1, n):
		if a[i] == '2':
			ss.add((i0, i))
			i0 = i
	ss.add((i0, i00))
	print('YES')
	for i in range(n):
		for j in range(n):
			if j == i:
				print('X', end='')
			elif (i, j) in ss:
				print('+', end='')
			elif (j, i) in ss:
				print('-', end='')
			else:
				print('=', end='')
		print()


def solve(values):
	n = len(values)
	ones = []
	twos = []
	for (pos, v) in enumerate(values):
		if v == '1':
			ones.append(pos)
		else:
			twos.append(pos)
	if not (len(twos) == 0 or len(twos) > 2):
		return None
	ans = [['='] * n for _ in range(n)]
	for x in range(n):
		ans[x][x] = 'X'
	for r in range(len(twos) - 1):
		o = twos[r]
		v = twos[r + 1]
		ans[o][v] = '+'
		ans[v][o] = '-'
	if twos:
		r = twos[-1]
		v = twos[0]
		ans[r][v] = '+'
		ans[v][r] = '-'
	return ans
for _ in range(int(input())):
	n = int(input())
	values = str(input())
	ans = solve(values)
	if ans:
		print('YES')
		for row in ans:
			print(''.join(row))
	else:
		print('NO')


n = int(input())
for i in range(n):
	length = int(input())
	word = input()
	win_index = [-1 for _ in range(length)]
	two_index = []
	for j in range(length):
		if word[j] == '2':
			two_index.append(j)
	if len(two_index) > 0 and len(two_index) < 3:
		print('NO')
	else:
		if len(two_index) > 1:
			for j in range(len(two_index) - 1):
				win_index[two_index[j]] = two_index[j + 1]
			win_index[two_index[-1]] = two_index[0]
		out = [[0 for _ in range(length)] for _ in range(length)]
		print('YES')
		for j in range(length):
			for k in range(length):
				if j == k:
					out[j][k] = 'X'
				elif word[j] == '1' or word[k] == '1':
					out[j][k] = '='
				elif out[j][k] == 0:
					if k == win_index[j]:
						out[j][k] = '+'
						out[k][j] = '-'
					else:
						out[j][k] = '-'
						out[k][j] = '+'
				print(out[j][k], end='')
			print()


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
import sys, io, os
input = sys.stdin.readline
inf = float('inf')
mod = 10 ** 9 + 7

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().strip()]
	m = [i for i in range(n) if l[i] == 2]
	arr = [['=' for i in range(n)] for j in range(n)]
	for i in range(n):
		arr[i][i] = 'X'
	if len(m) == 0:
		print('YES')
		for i in arr:
			print(*i, sep='')
	elif len(m) <= 2:
		print('NO')
	else:
		print('YES')
		m += [m[0]]
		for i in range(len(m) - 1):
			f = m[i]
			s = m[i + 1]
			arr[f][s] = '+'
			arr[s][f] = '-'
		for i in arr:
			print(*i, sep='')


import math
import collections
from functools import lru_cache
import heapq

def process(case, n, s):
	t1 = t2 = 0
	for i in range(n):
		if s[i] == '1':
			t1 += 1
		else:
			t2 += 1
	res = []
	for i in range(n):
		res.append(['='] * n)
	for i in range(n):
		wins = 0
		for j in range(n):
			if i == j % n:
				res[i][j % n] = 'X'
			elif s[i] == '2' and wins == 0 and (s[j % n] == '2') and (res[j % n][i] == '='):
				wins += 1
				res[i][j % n] = '+'
				res[j][i] = '-'
		if s[i] == '2' and wins == 0:
			print('NO')
			return
	print('YES')
	for i in range(n):
		print(''.join(res[i]))
tcs = int(input())
for tc in range(tcs):
	n = int(input())
	s = input().rstrip()
	process(tc + 1, n, s)


import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
import itertools
import functools
from types import GeneratorType
sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
graphDict = collections.defaultdict
queue = collections.deque

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		to = f(*args, **kwargs)
		if stack:
			return to
		else:
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						return to
					to = stack[-1].send(to)
	return wrappedfunc

class Graphs:

	def __init__(self):
		self.graph = graphDict(set)

	def add_edge(self, u, v):
		self.graph[u].add(v)
		self.graph[v].add(u)

	def dfs_utility(self, nodes, visited_nodes):
		visited_nodes.add(nodes)
		for neighbour in self.graph[nodes]:
			if neighbour not in visited_nodes:
				self.dfs_utility(neighbour, visited_nodes)

	def dfs(self, node):
		Visited = set()
		self.dfs_utility(i, Visited)

	def bfs(self, node, f_node):
		count = float('inf')
		visited = set()
		level = 0
		if node not in visited:
			queue.append([node, level])
			visited.add(node)
		flag = 0
		while queue:
			parent = queue.popleft()
			if parent[0] == f_node:
				flag = 1
				count = min(count, parent[1])
			level = parent[1] + 1
			for item in self.graph[parent[0]]:
				if item not in visited:
					queue.append([item, level])
					visited.add(item)
		return count if flag else -1

class Tree:

	def __init__(self, data):
		self.data = data
		self.left = None
		self.right = None

def inorder(node, lis):
	if node:
		inorder(node.left, lis)
		lis.append(node.data)
		inorder(node.right, lis)
	return lis

def leaf_node_sum(root):
	if root is None:
		return 0
	if root.left is None and root.right is None:
		return root.data
	return leaf_node_sum(root.left) + leaf_node_sum(root.right)

def hight(root):
	if root is None:
		return -1
	if root.left is None and root.right is None:
		return 0
	return max(hight(root.left), hight(root.right)) + 1

class UF:

	def __init__(self, N):
		self._id = list(range(N))
		self._count = N
		self._rank = [0] * N

	def find(self, p):
		id = self._id
		while p != id[p]:
			p = id[p] = id[id[p]]
		return p

	def count(self):
		return self._count

	def connected(self, p, q):
		return self.find(p) == self.find(q)

	def union(self, p, q):
		id = self._id
		rank = self._rank
		i = self.find(p)
		j = self.find(q)
		if i == j:
			return
		self._count -= 1
		if rank[i] < rank[j]:
			id[i] = j
		elif rank[i] > rank[j]:
			id[j] = i
		else:
			id[j] = i
			rank[i] += 1

	def __str__(self):
		return ' '.join([str(x) for x in self._id])

	def __repr__(self):
		return 'UF(' + str(self) + ')'

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0), []))

def p_sum(array):
	return list(itertools.accumulate(array))

def diophantine(a: int, b: int, c: int):
	(d, x, y) = extended_gcd(a, b)
	r = c // d
	return (r * x, r * y)

@bootstrap
def extended_gcd(a: int, b: int):
	if b == 0:
		(d, x, y) = (a, 1, 0)
	else:
		(d, p, q) = (yield extended_gcd(b, a % b))
		x = q
		y = p - q * (a // b)
	yield (d, x, y)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, **kwargs):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def inp():
	return sys.stdin.readline().strip()

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	n = int(inp())
	s = inp()
	a = s.count('1')
	b = s.count('2')
	if b == 1 or b == 2:
		print('NO')
	else:
		visited = set()
		ans = [['X' for row in range(n)] for col in range(n)]
		for i in range(n):
			for j in range(n):
				if i == j:
					continue
				if s[i] == '1' or s[j] == '1':
					ans[i][j] = '='
				elif ans[i][j] == 'X':
					if i not in visited:
						visited.add(i)
						ans[i][j] = '+'
						ans[j][i] = '-'
					else:
						ans[i][j] = '-'
						ans[j][i] = '+'
						visited.add(j)
		print('YES')
		for i in range(n):
			print(''.join(ans[i]))


def helper(s, n):
	c = 0
	arr = [['0' for i in range(n)] for j in range(n)]
	for i in range(n):
		for j in range(n):
			if i == j:
				arr[i][j] = 'X'
	for i in range(len(s)):
		if s[i] == '1':
			for k in range(n):
				if i != k:
					arr[i][k] = '='
					arr[k][i] = '='
	for i in range(len(s)):
		if s[i] == '2':
			c = 0
			for k in range(n):
				if arr[i][k] == '0':
					arr[i][k] = '+'
					arr[k][i] = '-'
					c = 1
					break
			if c == 0:
				return False
	print('YES')
	for i in range(n):
		for j in range(n):
			if arr[i][j] == '0':
				print('=', end='')
			else:
				print(arr[i][j], end='')
		print()
	return True
for _ in range(int(input())):
	n = int(input())
	s = input()
	if not helper(s, n):
		print('NO')


t = int(input())
from collections import Counter
for i in range(t):
	n = int(input())
	ex = list(input())
	ans = [['='] * n for m in range(n)]
	c = Counter(ex)
	if c['2'] == 1 or c['2'] == 2:
		print('NO')
		continue
	print('YES')
	for j in range(0, n):
		ans[j][j] = 'X'
	for j in range(0, n):
		if ex[j] == '2':
			for k in range(j + 1, n + j):
				if ex[k % n] == '2':
					ans[j][k % n] = '+'
					ans[k % n][j] = '-'
					break
	for j in range(n):
		print(''.join(ans[j]))


from collections import Counter
from sys import stdin, stdout
import math
from collections import defaultdict
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = list(str(input()))
	ans = [[0 for _ in range(n)] for _ in range(n)]
	for i in range(n):
		ans[i][i] = 'X'
	for i in range(n):
		if s[i] == '1':
			for j in range(n):
				if ans[i][j] != 'X':
					ans[i][j] = '='
					ans[j][i] = '='
	if s.count('1') == n:
		print('YES')
		for i in range(n):
			for j in range(n):
				print(ans[i][j], end='')
			print()
	else:
		for i in range(n):
			if s[i] == '2':
				ccc = False
				for j in range(n):
					if ans[i][j] == '+':
						ccc = True
					elif ans[i][j] == 0:
						if ccc == True:
							ans[i][j] = '-'
							ans[j][i] = '+'
						else:
							ans[i][j] = '+'
							ans[j][i] = '-'
							ccc = True
		cc = False
		for i in range(n):
			if s[i] == '2':
				if ans[i].count('+') > 0:
					pass
				else:
					cc = True
					break
		if cc == True:
			print('NO')
		else:
			print('YES')
			for i in range(n):
				for j in range(n):
					print(ans[i][j], end='')
				print()


t = int(input())
for p in range(t):
	n = int(input())
	s = str(input())
	ans = []
	for i in range(n):
		l = [0 for j in range(n)]
		ans.append(l)
	for i in range(n):
		for j in range(n):
			if i == j:
				ans[i][j] = 'X'
			elif s[i] == '2' and s[j] == '2' and (ans[j][i] != '+'):
				ans[i][j] = '+'
				ans[j][i] = '-'
				break
	flag = 0
	for i in range(n):
		cnt = 0
		for j in range(n):
			if s[i] == '1' and ans[i][j] == '-':
				flag = 1
				break
			if s[i] == '2' and ans[i][j] == '+':
				cnt += 1
		if s[i] == '2' and cnt == 0:
			flag = 1
		if flag:
			break
	if flag:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			for j in range(n):
				if i == j:
					ans[i][j] = 'X'
		for i in range(n):
			for j in range(n):
				if ans[i][j] != '+' and ans[i][j] != '-' and (ans[i][j] != 'X'):
					print('=', end='')
				else:
					print(ans[i][j], end='')
			print()


for p in range(int(input())):
	(n, l) = (int(input()), list(input()))
	(d, a) = ([x for x in range(n) if l[x] == '2'], [])
	if d:
		(x, y) = (d[0], d[-1])
		if x == y or len(d) < 3:
			print('NO')
			continue
	else:
		(x, y) = (-1, -1)
	for p in range(n):
		if l[p] == '1':
			r = ['='] * n
			r[p] = 'X'
		elif p == x:
			r = ['+' if x in d else '=' for x in range(n)]
			r[p] = 'X'
			r[y] = '-'
		elif p == y:
			r = ['-' if x in d else '=' for x in range(n)]
			r[p] = 'X'
			r[x] = '+'
		else:
			r = ['='] * n
			r[p] = 'X'
			r[y] = '+'
			r[x] = '-'
		a.append(r)
	print('YES')
	[print(''.join(x)) for x in a]


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
import bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10 ** 6
	n = random.randint(1, N)
	a = [random.randint(1, n) for i in range(n)]
	return (n, a)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = 1 << 63
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
alp = [chr(ord('a') + i) for i in range(26)]
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	n = I()
	s = [int(i) - 1 for i in input()]
	b = sum(s)
	if 1 <= b <= 2:
		print('NO')
		continue
	t = []
	for i in range(n):
		if s[i]:
			t += (i,)
	a = [['='] * n for i in range(n)]
	for i in range(n):
		a[i][i] = 'X'
	for i in range(b):
		a[t[i]][t[(i + 1) % b]] = '+'
		a[t[(i + 1) % b]][t[i]] = '-'
	print('YES')
	for i in a:
		print(''.join(i))


t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	st2 = []
	for i in range(n):
		ans.append([])
		for j in range(n):
			if i == j:
				ans[i].append('X')
			else:
				ans[i].append('=')
	pl = input()
	sum = 0
	for i in range(n):
		if pl[i] == '2':
			sum += 1
			st2.append(i)
	if sum == 1 or sum == 2:
		print('NO')
		continue
	print('YES')
	if sum != 0:
		for i in range(sum - 1):
			ans[st2[i]][st2[i + 1]] = '+'
			ans[st2[i + 1]][st2[i]] = '-'
		ans[st2[sum - 1]][st2[0]] = '+'
		ans[st2[0]][st2[sum - 1]] = '-'
	for i in range(n):
		print(''.join(ans[i]))


from math import ceil, gcd, inf, sqrt
from bisect import bisect_left
from collections import Counter, deque
mod = 1000000007
lt = 100001

def pro(arr):
	n = len(arr)
	ans = []
	for i in range(n):
		ans.append(['='] * n)
	for i in range(n):
		f = 0
		for j in range(i, n):
			if i == j:
				ans[i][j] = 'X'
				continue
			if arr[i] == '1':
				ans[i][j] = '='
			elif f == 0:
				if arr[j] == '2':
					ans[i][j] = '+'
					ans[j][i] = '-'
					f = 1
			elif arr[j] == '2':
				ans[i][j] = '-'
				ans[j][i] = '+'
			else:
				ans[i][j] = '='
	for i in range(n):
		if arr[i] == '2' and ans[i].count('+') < 1:
			print('NO')
			return
	print('YES')
	for i in range(n):
		print(''.join(ans[i]))
t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	pro(list(a))


for _ in range(int(input())):
	(n, s) = (int(input()), input())
	p = [*filter(lambda i: s[i] == '2', range(n))]
	if 0 < len(p) < 3:
		print('NO')
		continue
	print('YES')
	a = [['='] * n for i in range(n)]
	for i in range(n):
		a[i][i] = 'X'
	for i in range(-1, len(p) - 1):
		(x, y) = (p[i], p[i + 1])
		(a[x][y], a[y][x]) = ('+', '-')
	for i in a:
		print(''.join(i))


t = int(input())
for tt in range(t):
	n = int(input())
	f = list(input())
	if 1 <= f.count('2') < 3:
		print('NO')
	else:
		print('YES')
		ans = [[0 for i in range(n)] for j in range(n)]
		for i in range(n):
			ans[i][i] = 'X'
			k = 0
			for j in range(i + 1, n):
				if f[i] == '1' or f[j] == '1':
					ans[i][j] = '='
					ans[j][i] = '='
				elif k == 0:
					ans[i][j] = '+'
					ans[j][i] = '-'
					k += 1
				else:
					ans[j][i] = '+'
					ans[i][j] = '-'
		for i in range(n):
			print(*ans[i], sep='')


def process(S):
	n = len(S)
	ones = set([])
	twos = set([])
	for i in range(n):
		if S[i] == '1':
			ones.add(i)
		else:
			twos.add(i)
	if 0 < len(twos) < 3:
		return ['NO', []]
	L = sorted(twos)
	d = {}
	for i in range(len(L) - 1):
		p1 = L[i]
		p2 = L[i + 1]
		d[p1, p2] = '+'
		d[p2, p1] = '-'
	if len(L) > 0:
		d[L[-1], L[0]] = '+'
		d[L[0], L[-1]] = '-'
	for i in range(n):
		d[i, i] = 'X'
		for j in range(i + 1, n):
			if (i, j) not in d:
				d[i, j] = '='
				d[j, i] = '='
	M = []
	for i in range(n):
		row = []
		for j in range(n):
			row.append(d[i, j])
		row = ''.join(row)
		M.append(row)
	return ['YES', M]
t = int(input())
for i in range(t):
	n = int(input())
	S = input()
	(a1, a2) = process(S)
	print(a1)
	if a1 == 'YES':
		for row in a2:
			print(row)


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
INF = 10 ** 10
YES = 'YES'
NO = 'NO'

def solve(N, S):
	A = [[''] * N for _ in range(N)]
	for i in range(N):
		A[i][i] = 'X'
	for i in range(N):
		if S[i] == '1':
			for j in range(N):
				if j == i:
					continue
				A[i][j] = '='
				A[j][i] = '='
	for i in range(N):
		if S[i] == '2':
			ok = False
			for j in range(N):
				if A[i][j] == '':
					A[i][j] = '+'
					A[j][i] = '-'
					ok = True
					break
			if not ok:
				return (False, A)
	for i in range(N):
		for j in range(N):
			if A[i][j] == '':
				A[i][j] = '='
	return (True, A)
T0 = int(input())
for _ in range(T0):
	N = int(input())
	S = input()
	(result, A) = solve(N, S)
	if result:
		print('YES')
		for row in A:
			print(''.join(row))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	mat = [['=' for _ in range(n)] for i in range(n)]
	for i in range(n):
		mat[i][i] = 'X'
	for i in range(n):
		if s[i] == '2':
			marked = True
			for j in range(i + 1, n):
				if s[j] == '2':
					if marked:
						mat[i][j] = '+'
						mat[j][i] = '-'
						marked = False
					else:
						mat[i][j] = '-'
						mat[j][i] = '+'
				else:
					mat[i][j] = '='
					mat[j][i] = '='
	for i in range(n):
		if s[i] == '1':
			for j in range(n):
				if mat[i][j] == '-':
					print('NO')
					break
		elif '+' not in mat[i]:
			print('NO')
			break
	else:
		print('YES')
		for val in mat:
			print(''.join((str(x) for x in val)))


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations, accumulate, zip_longest, combinations_with_replacement
from math import gcd, floor, inf, log2, sqrt, log10, factorial
from bisect import bisect_right, bisect_left
from statistics import mode
from string import ascii_lowercase, ascii_uppercase
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, nlargest, nsmallest, merge
from copy import deepcopy
cases = int(input())
for _ in range(cases):
	num = int(input())
	s = input()
	total = num * (num - 1) // 2
	each = num - 1
	must_eq = 0
	for char in s:
		if char == '1':
			must_eq += each
			each -= 1
	if must_eq + s.count('2') > total:
		print('NO')
	else:
		print('YES')
		equal = {i for (i, char) in enumerate(s) if char == '1'}
		ans = [['='] * num for _ in range(num)]
		win_added = set()
		for i in range(num):
			for j in range(num):
				if ans[i][j] != '=':
					continue
				if i == j:
					ans[i][j] = 'X'
				elif i in equal or j in equal:
					ans[i][j] = '='
				elif i not in win_added:
					ans[i][j] = '+'
					ans[j][i] = '-'
					win_added.add(i)
		for row in ans:
			print(''.join(row))


def solve(n, l):
	twoCount = l.count('2')
	if twoCount > 0 and twoCount < 3:
		print('NO')
		return 0
	print('YES')
	ans = [['=' for i in range(n)] for j in range(n)]
	twos = []
	for i in range(n):
		if l[i] == '1':
			ans[i] = ['='] * n
		else:
			twos.append(i)
	if not len(twos) == 0:
		for i in range(len(twos) - 1):
			ans[twos[i]][twos[i + 1]] = '+'
			ans[twos[i + 1]][twos[i]] = '-'
		ans[twos[0]][twos[-1]] = '-'
		ans[twos[-1]][twos[0]] = '+'
	for i in range(n):
		ans[i][i] = 'X'
	for i in range(n):
		print(''.join(ans[i]))
t = int(input())
for case in range(t):
	n = int(input())
	l = list(input())
	solve(n, l)


from collections import *
from math import ceil

def il():
	return list(map(int, list(input())))

def ii():
	return int(input())

def imi():
	return map(int, input().split())
t = ii()
for _ in range(t):
	n = ii()
	li = il()
	c = 2
	for i in range(n):
		if li[i] == 2:
			li[i] = c
			c += 1
	y = c - 2
	if 0 < y <= 2:
		print('NO')
		continue
	print('YES')
	st = ''
	for i in range(n):
		for j in range(n):
			if i == j:
				st += 'X'
			elif min(li[i], li[j]) == 1:
				st += '='
			elif li[i] == 2 and li[j] == y + 1:
				st += '-'
			elif li[j] == 2 and li[i] == y + 1:
				st += '+'
			elif li[i] < li[j]:
				st += '+'
			else:
				st += '-'
		print(st)
		st = ''


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	s = input().strip()
	cnt = 0
	d = set()
	others = []
	for i in range(n):
		if s[i] == '1':
			cnt += 1
			d.add(i)
		elif len(others) < 3:
			others.append(i)
	if cnt == n:
		print('YES')
		arr = ['='] * n
		for i in range(n):
			arr[i] = 'X'
			print(''.join(arr))
			arr[i] = '='
	elif n - cnt >= 3:
		print('YES')
		arr = ['='] * n
		arr2 = ['-'] * n
		for j in d:
			arr2[j] = '='
		idx = 1
		for i in range(n):
			if i in d:
				arr[i] = 'X'
				print(''.join(arr))
				arr[i] = '='
			elif idx < 4:
				arr2[i] = 'X'
				arr2[others[idx % len(others)]] = '+'
				print(''.join(arr2))
				arr2[others[idx % len(others)]] = '-'
				idx += 1
				arr2[i] = '-'
			else:
				ans = list('+' * i + 'X' + '-' * (n - i - 1))
				for j in d:
					ans[j] = '='
				print(''.join(ans))
	else:
		print('NO')
	return
for _ in range(int(input())):
	main()


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	l = [['X' if i == j else '=' for j in range(n)] for i in range(n)]
	if s.count('2') in [1, 2]:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			if s[i] == '2':
				try:
					a = s.index('2', i + 1)
				except:
					a = s.index('2', 0, i)
				(l[i][a], l[a][i]) = ('+', '-')
		for i in l:
			a = ''
			for j in i:
				a += j
			print(a)


for _ in range(int(input())):
	n = int(input())
	s = input()
	c = s.count('2')
	if c == 1 or c == 2:
		print('NO')
		continue
	else:
		print('YES')
	ans = [['='] * n for _ in range(n)]
	t = [0] * c
	curr = 0
	for i in range(n):
		if s[i] == '2':
			t[curr] = i
			curr += 1
	curr = 0
	for i in range(n):
		ans[i][i] = 'X'
		if s[i] == '2':
			if curr < c - 1:
				ans[i][t[curr + 1]] = '+'
				ans[t[curr + 1]][i] = '-'
			else:
				ans[i][t[0]] = '+'
				ans[t[0]][i] = '-'
			curr += 1
	for i in range(n):
		temp = ''
		for j in range(n):
			temp += ans[i][j]
		print(temp)


def main():
	from sys import stdin
	input = stdin.readline
	for _ in range(int(input())):
		(n, s) = (int(input()), input())
		ans = [['.'] * n for _ in range(n)]
		cnt = [0] * n
		for i in range(n):
			for j in range(i, n):
				if i == j:
					ans[i][i] = 'X'
					continue
				if s[i] == '1' and s[j] == '1':
					ans[i][j] = ans[j][i] = '='
				elif s[i] == '1' and s[j] == '2':
					ans[i][j] = ans[j][i] = '='
				elif s[i] == '2' and s[j] == '1':
					ans[i][j] = ans[j][i] = '='
				elif not cnt[i]:
					cnt[i] += 1
					(ans[i][j], ans[j][i]) = ('+', '-')
				else:
					cnt[j] += 1
					(ans[i][j], ans[j][i]) = ('-', '+')
		flag = True
		for i in range(n):
			if s[i] == '2' and (not cnt[i]):
				flag = False
				break
		if flag:
			print('YES')
			print(*[''.join(ans[i]) for i in range(n)], sep='\n')
		else:
			print('NO')
main()


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
import sys, io, os
input = sys.stdin.readline
inf = float('inf')
mod = 10 ** 9 + 7

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().strip()]
	m = [i for i in range(n) if l[i] == 2]
	arr = [['=' for i in range(n)] for j in range(n)]
	for i in range(n):
		arr[i][i] = 'X'
	if len(m) == 0:
		print('YES')
		for i in arr:
			print(*i, sep='')
	elif len(m) <= 2:
		print('NO')
	else:
		print('YES')
		m += [m[0]]
		for i in range(len(m) - 1):
			f = m[i]
			s = m[i + 1]
			arr[f][s] = '+'
			arr[s][f] = '-'
		for i in arr:
			print(*i, sep='')


for _ in range(int(input())):
	n = int(input())
	s = input()
	c2 = s.count('2')
	if c2 and c2 < 3:
		print('NO')
	else:
		min2 = None
		print('YES')
		a = [['='] * n for _ in range(n)]
		for i in range(n):
			a[i][i] = 'X'
			if s[i] == '2':
				if min2 is None:
					min2 = i
				found2 = False
				for j in range(i + 1, n):
					if s[j] == '2':
						found2 = True
						a[i][j] = '+'
						a[j][i] = '-'
						break
				if not found2:
					a[i][min2] = '+'
					a[min2][i] = '-'
		for i in a:
			print(''.join(i))


tests = int(input())
for t in range(tests):
	n = int(input())
	s = input()
	win = s.count('2')
	if 0 < win <= 2:
		print('NO')
	else:
		print('YES')
		firstWinner = s.find('2')
		lastWinner = s.rfind('2')
		for i in range(len(s)):
			answer = ['='] * n
			answer[i] = 'X'
			if s[i] == '2':
				if i == firstWinner:
					answer[lastWinner] = '-'
					answer[s.find('2', i + 1)] = '+'
				elif i == lastWinner:
					answer[firstWinner] = '+'
					answer[s.rfind('2', 0, i)] = '-'
				else:
					answer[s.find('2', i + 1)] = '+'
					answer[s.rfind('2', 0, i)] = '-'
			print(''.join(answer))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	ans = [['='] * n for _ in range(n)]
	for i in range(n):
		ans[i][i] = 'X'
	bs = []
	for i in range(n):
		if s[i] == '2':
			bs.append(i)
	if len(bs) == 1 or len(bs) == 2:
		print('NO')
		continue
	print('YES')
	for i in range(len(bs)):
		st = bs[i]
		ed = bs[(i + 1) % len(bs)]
		ans[st][ed] = '+'
		ans[ed][st] = '-'
	for i in range(n):
		print(''.join(ans[i]))