A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters '+' and '1'. For example, sequences '(())()', '()', and '(()(()))' are balanced, while ')(', '(()', and '(()))(' are not.

You are given a binary string $s$ of length $n$. Construct two balanced bracket sequences $a$ and $b$ of length $n$ such that for all $1\le i\le n$:

if $s_i=1$, then $a_i=b_i$

if $s_i=0$, then $a_i\ne b_i$

If it is impossible, you should report about it.


-----Input-----

The first line contains a single integer $t$ ($1\le t\le 10^4$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($2\le n\le 2\cdot 10^5$, $n$ is even).

The next line contains a string $s$ of length $n$, consisting of characters 0 and 1.

The sum of $n$ across all test cases does not exceed $2\cdot 10^5$.


-----Output-----

If such two balanced bracked sequences exist, output "YES" on the first line, otherwise output "NO". You can print each letter in any case (upper or lower).

If the answer is "YES", output the balanced bracket sequences $a$ and $b$ satisfying the conditions on the next two lines.

If there are multiple solutions, you may print any.


-----Examples-----

Input
3
6
101101
10
1001101101
4
1100
Output
YES
()()()
((()))
YES
()()((()))
(())()()()
NO


-----Note-----

In the first test case, $a=$"()()()" and $b=$"((()))". The characters are equal in positions $1$, $3$, $4$, and $6$, which are the exact same positions where $s_i=1$.

In the second test case, $a=$"()()((()))" and $b=$"(())()()()". The characters are equal in positions $1$, $4$, $5$, $7$, $8$, $10$, which are the exact same positions where $s_i=1$.

In the third test case, there is no solution.

Difficulty: MEDIUM_HARD
Tags: Greedy algorithms

Constructive algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
def solve(n, s):
	cnt = 0
	for i in s:
		if i == '1':
			cnt += 1
	if cnt % 2 == 1 or s[0] == '0' or s[-1] == '0':
		print('NO')
		return
	k = 0
	flip = 0
	a = ''
	b = ''
	for i in range(n):
		if s[i] == '1':
			if 2 * k < cnt:
				a += '('
			else:
				a += ')'
			b += a[-1]
			k += 1
		else:
			if flip == 1:
				a += '('
				b += ')'
			else:
				a += ')'
				b += '('
			flip = not flip
	print('YES')
	print(a)
	print(b)
	return
for t in range(int(input())):
	n = int(input())
	s = input()
	solve(n, s)


from sys import stdin, stdout
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd
for _ in range(it()):
	n = it()
	l = list(input())
	c = C(l)
	if l[0] == '0' or l[-1] == '0' or n & 1 or c['0'] & 1 or c['1'] & 1:
		print('NO')
		continue
	else:
		(a, b) = (['('], ['('])
		(o, z) = (1, 0)
		for i in range(1, n):
			if l[i] == '1':
				if o < c['1'] // 2:
					a.append('(')
					b.append('(')
				else:
					a.append(')')
					b.append(')')
				o += 1
			else:
				if z & 1:
					a.append('(')
					b.append(')')
				else:
					a.append(')')
					b.append('(')
				z += 1
		print('YES')
		print(''.join(a))
		print(''.join(b))


for _ in range(int(input())):
	n = int(input())
	s = [int(a) for a in input()]
	cnt = sum(s)
	if s[0] and s[-1] and n & 1 ^ 1 and cnt & 1 ^ 1:
		(a, b, p) = ([0] * n, [0] * n, 1)
		for (i, x) in enumerate(s):
			if x:
				if cnt > 0:
					a[i] = b[i] = 1
					cnt -= 2
			else:
				a[i] = p
				p ^= 1
				b[i] = p
		print('YES', ''.join(['(' if x else ')' for x in a]), ''.join(['(' if x else ')' for x in b]), sep='\n')
	else:
		print('NO')


from collections import deque
for _ in range(int(input())):
	n = int(input())
	s = input()
	c1 = s.count('1')
	c = c1
	d = 0
	if s[0] == '1' and s[-1] == '1' and (s.count('0') % 2 == 0) and (c1 % 2 == 0):
		br1 = ['('] * n
		br2 = ['('] * n
		for k in range(n):
			if s[k] == '1':
				if c1 > c // 2:
					c1 -= 1
				else:
					br1[k] = ')'
					br2[k] = ')'
			else:
				if d % 2 == 0:
					br1[k] = '('
					br2[k] = ')'
				else:
					br2[k] = '('
					br1[k] = ')'
				d += 1
		print('YES')
		print(*br1, sep='')
		print(*br2, sep='')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = str(input())
	res1 = ''
	res2 = ''
	zero = s.count('0')
	one = s.count('1')
	a = one / 2
	if s[0] == '0' or s[n - 1] == '0' or zero % 2 == 1 or (one % 2 == 1):
		print('no')
	else:
		a = int(one / 2)
		u = 0
		v = 0
		for j in range(n):
			if s[j] == '1':
				u += 1
				if u <= a:
					res1 = res1 + '('
					res2 = res2 + '('
				else:
					res1 = res1 + ')'
					res2 = res2 + ')'
			elif v == 0:
				res1 = res1 + '('
				res2 = res2 + ')'
				v += 1
			else:
				res1 = res1 + ')'
				res2 = res2 + '('
				v -= 1
		print('yes')
		print(res1)
		print(res2)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	cnt = 0
	for i in range(n):
		if s[i] == '1':
			cnt += 1
	if cnt % 2 != 0 or s[0] == '0' or s[-1] == '0':
		print('NO')
	else:
		flag = 0
		k = 0
		a = ''
		b = ''
		for i in range(n):
			if s[i] == '1':
				if k < cnt // 2:
					a += '('
					b += '('
					k += 1
				else:
					a += ')'
					b += ')'
			elif flag == 0:
				a += '('
				b += ')'
				flag = 1
			else:
				a += ')'
				b += '('
				flag = 0
		print('YES')
		print(a)
		print(b)


for test in range(int(input())):
	n = int(input())
	s = input()
	cnt = s.count('1')
	if cnt & 1 or s[0] == '0' or s[-1] == '0':
		print('NO')
		continue
	c = 1
	k = 0
	a = ''
	b = ''
	for i in range(n):
		if s[i] == '1':
			if 2 * k < cnt:
				a += '('
				b += a[-1]
			else:
				a += ')'
				b += a[-1]
			k += 1
		else:
			if c:
				a += '('
				b += ')'
			else:
				a += ')'
				b += '('
			c ^= 1
	print('YES')
	print(a)
	print(b)


import sys, math, itertools, random, bisect
from collections import defaultdict
INF = 10 ** 18

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

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

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	s = input()
	cnt = s.count('1')
	if cnt & 1 or s[0] == '0' or s[-1] == '0':
		print('NO')
	else:
		(a, b) = ('', '')
		k = 0
		flip = False
		for i in range(n):
			if s[i] == '1':
				if 2 * k < cnt:
					a += '('
				else:
					a += ')'
				b += a[-1]
				k += 1
			else:
				if flip:
					a += '('
					b += ')'
				else:
					a += ')'
					b += '('
				flip = not flip
		print('YES')
		print(a)
		print(b)


for q in range(int(input())):
	n = int(input())
	s = input()
	x = s.count('1')
	y = s.count('0')
	a_str = ''
	b_str = ''
	possible = True
	if y % 2 == 1:
		possible = False
	else:
		xh = x // 2
		yh = y // 2
		openx = 0
		a_open = 0
		b_open = 0
		for i in range(n):
			if s[i] == '1':
				if openx < xh:
					openx += 1
					a_open += 1
					b_open += 1
					a_str += '('
					b_str += '('
				elif a_open == 0 or b_open == 0:
					possible = False
					break
				else:
					a_open -= 1
					b_open -= 1
					a_str += ')'
					b_str += ')'
			elif a_open == 0 and b_open == 0:
				possible = False
				break
			elif a_open >= b_open:
				a_open -= 1
				a_str += ')'
				b_open += 1
				b_str += '('
			else:
				a_open += 1
				a_str += '('
				b_open -= 1
				b_str += ')'
	if possible:
		print('YES')
		print(a_str)
		print(b_str)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	z = 0
	o = 0
	if a[0] != '1' or a[-1] != '1':
		print('NO')
	else:
		d = {}
		for i in range(n):
			if a[i] == '1':
				o += 1
		z = n - o
		if z % 2 != 0:
			print('NO')
		else:
			print('YES')
			c = 0
			e = 0
			s1 = ''
			s2 = ''
			for i in range(n):
				if a[i] == '1':
					if c < o // 2:
						s1 += '('
						s2 += '('
						c = c + 1
					else:
						s1 += ')'
						s2 += ')'
				elif e == 0:
					s1 += '('
					s2 += ')'
					e = 1
				else:
					s1 += ')'
					s2 += '('
					e = 0
			print(s1)
			print(s2)


import sys
import collections
import math
import bisect
import heapq
inf = sys.maxsize

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

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

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	n = int(input())
	s = input()
	if all((s[i] == '0' for i in range(n))):
		print('NO')
		continue
	if s[0] == '0' or s[-1] == '0':
		print('NO')
		continue
	zeros = s.count('0')
	ones = s.count('1')
	if zeros % 2 or ones % 2:
		print('NO')
		continue
	print('YES')
	a = ''
	b = ''
	c1 = 1
	c2 = 0
	for i in range(n):
		if s[i] == '1':
			if c1 <= ones // 2:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
			c1 += 1
		else:
			if c2 == 0:
				a += ')'
				b += '('
			else:
				a += '('
				b += ')'
			c2 ^= 1
	print(a)
	print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if s[0] == '0' or s[-1] == '0' or s.count('0') % 2 == 1 or (s.count('1') % 2 == 1):
		print('NO')
		continue
	zero = s.count('0')
	one = s.count('1')
	zopen = zero // 2
	zclose = zero // 2
	oopen = one // 2
	oclose = one // 2
	a = ''
	b = ''
	cura = 0
	curb = 0
	flag = 0
	for i in range(n):
		if s[i] == '1':
			if oopen > 0:
				a += '('
				b += '('
				cura += 1
				curb += 1
				oopen -= 1
			elif oclose > 0 and cura - 1 >= 0 and (curb - 1 >= 0):
				a += ')'
				b += ')'
				cura -= 1
				curb -= 1
				oclose -= 1
			else:
				flag = 1
		else:
			if curb >= cura and zopen > 0:
				a += '('
				b += ')'
				cura += 1
				curb -= 1
				zopen -= 1
			else:
				a += ')'
				b += '('
				cura -= 1
				curb += 1
				zclose -= 1
			if cura < 0 or curb < 0:
				flag = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')
		print(a)
		print(b)


from sys import stdin, stdout
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import *
from random import *
input = stdin.readline
prin = stdout.write
from random import sample
from collections import Counter, deque
from fractions import *
from math import sqrt, ceil, log2, gcd
mod = 10 ** 9 + 7

def f(arr, i, j, d, dist):
	if i == j:
		return
	nn = max(arr[i:j])
	for tl in range(i, j):
		if arr[tl] == nn:
			dist[tl] = d
			f(arr, i, tl, d + 1, dist)
			f(arr, tl + 1, j, d + 1, dist)

def ps(n):
	cp = 0
	lk = 0
	arr = {}
	while n % 2 == 0:
		n = n // 2
		lk += 1
	for ps in range(3, ceil(sqrt(n)) + 1, 2):
		lk = 0
		cc = 0
		while n % ps == 0:
			n = n // ps
			lk += 1
	if n != 1:
		lk += 1
		return False
	return True

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

def factorials(n, r):
	slr = n
	dpr = r
	qlr = 1
	qs = 1
	mod = 10 ** 9 + 7
	for ip in range(n - r + 1, n + 1):
		qlr = qlr * ip % mod
	for ij in range(1, r + 1):
		qs = qs * ij % mod
	ans = qlr * modInverse(qs) % mod
	return ans

def modInverse(b):
	qr = 10 ** 9 + 7
	return pow(b, qr - 2, qr)
from types import GeneratorType

def iterative(f, stack=[]):

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

def power(arr):
	listrep = arr
	subsets = []
	for i in range(2 ** len(listrep)):
		subset = []
		for k in range(len(listrep)):
			if i & 1 << k:
				subset.append(listrep[k])
		subsets.append(subset)
	return subsets

def pda(n):
	list = []
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				list.append(i)
			else:
				list.append(n // i)
				list.append(i)
	return list

def dis(xa, ya, xb, yb):
	return sqrt((xa - xb) ** 2 + (ya - yb) ** 2)

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

def ilist():
	return [int(x) for x in input().strip().split()]

def islist():
	return list(map(str, input().split().rstrip()))

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

def google(test, ans):
	return 'Case #' + str(test) + ': ' + str(ans)

def overlap(x1, y1, x2, y2):
	if x2 > y1:
		return y1 - x2
	if y1 > y2:
		return y2 - x2
	return y1 - x2

def pal(s):
	k = len(s)
	n = len(s) // 2
	for i in range(n):
		if s[i] == s[k - 1 - i]:
			continue
		else:
			return 0
	return 1
t = int(input())
for p in range(t):
	n = ii()
	a = inp()
	b = a
	xy = a.count('0')
	if xy % 2 == 1 or a[0] == '0' or a[-1] == '0':
		print('No')
		continue
	ac = ''
	bc = ''
	az = a.count('1') // 2
	one = 0
	bit = 0
	for i in range(n):
		if a[i] == '0':
			if bit == 0:
				ac += '('
				bc += ')'
			else:
				ac += ')'
				bc += '('
			bit ^= 1
		else:
			if one < az:
				ac += '('
				bc += '('
			else:
				ac += ')'
				bc += ')'
			one += 1
	prin('YES' + '\n')
	prin(ac + '\n')
	prin(bc + '\n')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	z = s.count('0')
	o = s.count('1')
	(a, b) = ('', '')
	if s[0] == '1' and s[n - 1] == '1' and (o % 2 == 0) and (z % 2 == 0):
		one = 0
		zero = 0
		for i in s:
			if i == '1':
				one += 1
				if one <= o // 2:
					a += '('
					b += '('
				else:
					a += ')'
					b += ')'
			else:
				zero += 1
				if zero % 2 == 0:
					a += '('
					b += ')'
				else:
					a += ')'
					b += '('
		print('YES')
		print(a)
		print(b)
	else:
		print('NO')


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	n = int(input())
	s = input()
	flag = True
	z = 0
	if s[0] == '0' or s[-1] == '0':
		flag = False
	for i in range(n):
		if s[i] == '0':
			z += 1
	if z % 2 != 0:
		flag = False
	if flag:
		print('YES')
		k = (n - z) // 2
		z = 0
		o = 0
		a = ''
		b = ''
		c = 0
		for i in range(n):
			if s[i] == '1':
				if o < k:
					a += '('
					o += 1
					c += 1
				else:
					a += ')'
					o += 1
					c -= 1
			else:
				z += 1
				if z % 2 != 0:
					a += ')'
				else:
					a += '('
		for i in range(n):
			if s[i] == '1':
				b += a[i]
			elif a[i] == '(':
				b += ')'
			else:
				b += '('
		print(a)
		print(b)
	else:
		print('NO')


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify
mod = 10 ** 9 + 7
INF = float('inf')

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

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

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = inps()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
for _ in range(inp()):
	n = inp()
	s = inpsl(n)
	if s[0] == '0' or s[-1] == '0' or s.count('1') % 2:
		print('NO')
		continue
	f = 0
	a = []
	b = []
	d = ['(', ')']
	cnt1 = s.count('1')
	cnt = 0
	for (i, x) in enumerate(s):
		if x == '1':
			cnt += 1
			if cnt <= cnt1 // 2:
				ind = 0
			else:
				ind = 1
			a.append(d[ind])
			b.append(d[ind])
		else:
			a.append(d[1 - f])
			b.append(d[f])
			f = 1 - f
	print('YES')
	print(''.join(a))
	print(''.join(b))


t = int(input())
for _ in range(t):
	n = int(input())
	S = input()
	if S[0] == '0' or S[-1] == '0':
		print('NO')
		continue
	cnt = 0
	for s in S:
		if s == '1':
			cnt += 1
	if cnt & 1:
		print('NO')
		continue
	k = 0
	a = ''
	b = ''
	flip = 1
	for s in S:
		if s == '1':
			k += 1
			a += '(' if 2 * k <= cnt else ')'
			b += a[-1]
		else:
			a += '(' if flip else ')'
			b += ')' if flip else '('
			flip ^= 1
	print('YES')
	print(a)
	print(b)


for _ in range(int(input())):
	n = int(input())
	s = list(map(str, input()))
	if n % 2 != 0:
		print('NO')
	elif s[0] == '0' or s[n - 1] == '0':
		print('NO')
	elif s.count('0') % 2 != 0:
		print('NO')
	else:
		a = '('
		b = ')'
		s1 = list.copy(s)
		s2 = list.copy(s)
		mid = s.count('1') // 2
		j = 1
		for i in range(n):
			if j <= mid:
				if s1[i] == '1':
					s1[i] = '('
					s2[i] = '('
					j += 1
				else:
					s1[i] = a
					s2[i] = b
					(a, b) = (b, a)
			elif s1[i] == '1':
				s1[i] = ')'
				s2[i] = ')'
			else:
				s1[i] = a
				s2[i] = b
				(a, b) = (b, a)
		print('YES')
		print(''.join(s1))
		print(''.join(s2))


def solve(s, n):
	cnt = 0
	for x in s:
		cnt += x == '1'
	c0 = n - cnt
	if cnt % 2 == 1:
		print('NO')
		return
	cnt //= 2
	a = b = ''
	sa = sb = 0
	for i in range(n):
		if s[i] == '1':
			if cnt > 0:
				a += '('
				b += '('
				sa += 1
				sb += 1
			else:
				a += ')'
				b += ')'
				sa -= 1
				sb -= 1
			cnt -= 1
		else:
			if c0 % 2 == 1:
				a += ')'
				b += '('
				sa -= 1
				sb += 1
			else:
				a += '('
				b += ')'
				sa += 1
				sb -= 1
			c0 -= 1
		if sa < 0 or sb < 0:
			print('NO')
			return
	print('YES')
	print(a)
	print(b)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	solve(s, n)


cases = int(input())
while cases:
	cases -= 1
	num = int(input())
	s = list(map(int, list(input())))
	if len(s) % 2 != 0 or s[0] == 0 or s[-1] == 0 or (s.count(0) % 2 != 0):
		print('NO')
	else:
		ones = s.count(1) // 2
		zeros = s.count(0)
		ans1 = ''
		ans2 = ''
		for n in s:
			if n == 1 and ones > 0:
				ans1 += '('
				ans2 += '('
				ones -= 1
			elif n == 1:
				ans1 += ')'
				ans2 += ')'
			elif n == 0 and zeros % 2 == 0:
				ans1 += '('
				ans2 += ')'
				zeros -= 1
			else:
				ans1 += ')'
				ans2 += '('
				zeros -= 1
		print('YES')
		print(ans1)
		print(ans2)


t = int(input())
for _ in range(t):
	n = int(input())
	temp = [int(i) for i in input()]
	(a, b) = ('', '')
	(temp_a, temp_b) = (0, 0)
	flag = 0
	k = temp.count(1)
	if n % 2 != 0 or temp[0] == 0 or temp[-1] == 0 or (k % 2 != 0):
		flag = 1
	(open_a, open_b) = (n // 2, n // 2)
	(close_a, close_b) = (n // 2, n // 2)
	k = k // 2
	f = 1
	for i in temp:
		if temp_a < 0 or temp_b < 0:
			break
		if i == 1:
			if k == 0:
				a += ')'
				b += ')'
				temp_a -= 1
				temp_b -= 1
			else:
				a += '('
				b += '('
				temp_a += 1
				temp_b += 1
				k -= 1
		else:
			if f:
				b += ')'
				a += '('
				temp_b -= 1
				temp_a += 1
			else:
				a += ')'
				b += '('
				temp_a -= 1
				temp_b += 1
			f = (f + 1) % 2
	if flag == 1 or temp_a != 0 or temp_b != 0:
		print('NO')
	else:
		print('YES')
		print(a)
		print(b)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	o = 0
	a = ''
	b = ''
	z = 0
	to = 0
	tz = 0
	if s[0] == '0' or s[n - 1] == '0':
		print('NO')
	else:
		for i in range(n):
			if s[i] == '1':
				o += 1
			else:
				z += 1
		if o % 2 != 0 or z % 2 != 0:
			print('NO')
		else:
			print('YES')
			for i in range(n):
				if s[i] == '1':
					to += 1
					if to <= o // 2:
						a += '('
					else:
						a += ')'
				else:
					tz += 1
					if tz % 2 != 0:
						a += '('
					else:
						a += ')'
			print(a)
			for i in range(n):
				if s[i] == '1':
					b += a[i]
				elif a[i] == '(':
					b += ')'
				else:
					b += '('
			print(b)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	x = 0
	y = 0
	f = 1
	one = s.count('1')
	half = one // 2
	if one % 2:
		f = 0
	for i in range(n):
		if x < 0 or y < 0:
			f = 0
			break
		if s[i] == '1':
			if half != 0:
				a += '('
				b += '('
				x += 1
				y += 1
				half -= 1
			else:
				a += ')'
				b += ')'
				x -= 1
				y -= 1
		elif x <= y:
			a += '('
			x += 1
			b += ')'
			y -= 1
		else:
			a += ')'
			x -= 1
			b += '('
			y += 1
	if x != 0 or y != 0 or f == 0:
		print('NO')
	else:
		print('YES')
		print(a)
		print(b)


for k in range(int(input())):
	n = int(input())
	s = input()
	(a, b) = ('', '')
	x = s.count('1')
	y = s.count('0')
	if s[0] != '1' or s[n - 1] != '1' or n % 2 != 0 or (x % 2 != 0) or (y % 2 != 0):
		print('NO')
	else:
		for i in range(n):
			if s[i] == '1':
				if x % 2 == 0 and x != 0:
					a += '('
					b += '('
					x -= 2
				else:
					a += ')'
					b += ')'
			elif y % 2 == 0:
				a += '('
				b += ')'
				y -= 1
			else:
				a += ')'
				b += '('
				y -= 1
		print('YES')
		print(a)
		print(b)


def solve():
	n = int(input())
	ip = input()
	ones = ip.count('1')
	zers = ip.count('0')
	if zers % 2 != 0 or ip[0] == '0' or ip[n - 1] == '0':
		print('NO')
	else:
		ans1 = ''
		ans2 = ''
		k = 0
		flag = 1
		for i in range(n):
			if ip[i] == '1':
				if k < ones // 2:
					ans1 = ans1 + '('
					ans2 = ans2 + '('
				else:
					ans1 = ans1 + ')'
					ans2 = ans2 + ')'
				k += 1
			else:
				if flag == 1:
					ans1 += '('
				else:
					ans1 += ')'
				if flag == 1:
					ans2 += ')'
				else:
					ans2 += '('
				if flag == 1:
					flag = 0
				else:
					flag = 1
		print('YES')
		print(ans1)
		print(ans2)
for _ in range(int(input())):
	solve()


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
mod1 = 1000000000 + 7
mod2 = 998244353
for _ in range(I()):
	n = I()
	s = S()
	if s[0] != '1' or s[-1] != '1' or s.count('0') % 2 != 0:
		print('NO')
		continue
	a = [0] * n
	b = [0] * n
	i = 0
	k = s.count('1') // 2
	p = f = 0
	for i in range(n):
		if s[i] == '1':
			if p < k:
				a[i] = '('
				b[i] = '('
			else:
				a[i] = ')'
				b[i] = ')'
			p += 1
	for i in range(n):
		if s[i] == '0':
			if f == 0:
				a[i] = '('
				b[i] = ')'
				f = 1
			else:
				a[i] = ')'
				b[i] = '('
				f = 0
	print('YES')
	print(''.join(a))
	print(''.join(b))


def solve():
	n = int(input())
	s = input()
	one = s.count('1')
	zero = s.count('0')
	if one % 2 == 1 or zero % 2 == 1 or s[0] == '0' or (s[n - 1] == '0'):
		print('NO')
		return
	a = ''
	b = ''
	for i in s:
		if i == '1':
			if one:
				a += '('
				b += '('
				one -= 2
			else:
				a += ')'
				b += ')'
		elif zero % 2 == 0:
			a += '('
			b += ')'
			zero -= 1
		else:
			a += ')'
			b += '('
			zero -= 1
	print('YES')
	print(a)
	print(b)
t = int(input())
while t > 0:
	t -= 1
	solve()


for t in range(int(input())):
	n = int(input())
	s = input()
	cnt = 0
	for i in s:
		cnt += i == '1'
	if s[0] == '0' or s[n - 1] == '0' or cnt % 2 == 1:
		print('NO')
		continue
	k = 0
	(a, b) = ('', '')
	flip = False
	for i in range(n):
		if s[i] == '1':
			if k * 2 < cnt:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
			k += 1
		else:
			if flip:
				a += ')'
				b += '('
			else:
				a += '('
				b += ')'
			flip = not flip
	print('YES')
	print(a)
	print(b)


T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	can = True
	if s.count('0') % 2 == 1:
		can = False
	elif n % 2 == 1:
		can = False
	elif s[0] == '0' or s[-1] == '0':
		can = False
	if not can:
		print('NO')
		continue
	parity = 0
	pdict = {0: '()', 1: ')('}
	a = []
	b = []
	h = 0
	for i in range(n):
		if s[i] == '0':
			a.append(pdict[parity][0])
			b.append(pdict[parity][1])
			parity = 1 - parity
		elif i == n - 1 or h >= 2:
			a.append(')')
			b.append(')')
			h -= 1
		else:
			a.append('(')
			b.append('(')
			h += 1
	print('YES')
	print(''.join(a))
	print(''.join(b))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

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

def LI1():
	return list(map(int1, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10 ** 16
md = 10 ** 9 + 7

def ng(aa):
	now = 0
	for a in aa:
		now += a
		if now < 0:
			return True
	return False
for _ in range(II()):
	n = II()
	n2 = n // 2
	s = SI()
	(zero, one) = ([], [])
	for (i, c) in enumerate(s):
		if c == '0':
			zero.append(i)
		else:
			one.append(i)
	if len(zero) & 1:
		print('NO')
		continue
	a = [1] * n
	b = [1] * n
	for i in range(len(zero)):
		if i & 1:
			a[zero[i]] = -1
		else:
			b[zero[i]] = -1
	for i in range(len(one) // 2, len(one)):
		a[one[i]] = -1
		b[one[i]] = -1
	if ng(b):
		print('NO')
		continue
	print('YES')
	a = ''.join(('(' if a[i] == 1 else ')' for i in range(n)))
	b = ''.join(('(' if b[i] == 1 else ')' for i in range(n)))
	print(a)
	print(b)


import sys, io, os
try:
	Z = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
except:
	Z = lambda : sys.stdin.readline().encode()
O = []
ch = '()'
for _ in range(int(Z())):
	n = int(Z())
	s = Z().strip()
	t = s.count(48)
	x = (n - t) // 2
	if t % 2 or s[0] == 48 or s[-1] == 48:
		O.append('NO')
		continue
	l1 = []
	l2 = []
	c0 = c1 = p = 0
	t //= 2
	q1 = []
	q2 = []
	for i in range(n):
		if s[i] % 2:
			c1 += 1
			b = c1 > x
			l1.append(ch[b])
			l2.append(ch[b])
		else:
			c0 += 1
			if c0 > t:
				q2.append(i)
			else:
				q1.append(i)
			l1.append('_')
			l2.append('_')
	q1 = q1[::-1]
	for i in range(t):
		v = q1.pop()
		w = q2.pop()
		l1[v] = ch[p]
		l2[v] = ch[1 - p]
		l1[w] = ch[1 - p]
		l2[w] = ch[p]
		p = 1 - p
	O.append('YES')
	O.append(''.join(l1))
	O.append(''.join(l2))
print('\n'.join(O))


inn = lambda : int(input())
inm = lambda : map(int, input().split())
ins = lambda : str(input())
ina = lambda : list(map(int, input().split()))

def solve():
	n = inn()
	ones = 0
	zeros = 0
	s = ins()
	for i in s:
		if i == '1':
			ones += 1
		else:
			zeros += 1
	if ones % 2 == 0 and zeros % 2 == 0:
		a = ''
		b = ''
		o = ones
		z = 0
		for i in s:
			if i == '1':
				if o > ones // 2:
					a += '('
					b += '('
				else:
					a += ')'
					b += ')'
				o -= 1
			else:
				if z == 0:
					a += '('
					b += ')'
				else:
					a += ')'
					b += '('
				z = 1 - z

		def check(t):
			cnt = 0
			for i in t:
				if i == '(':
					cnt += 1
				else:
					cnt -= 1
				if cnt < 0:
					return False
			if cnt:
				return False
			return True
		if check(a) and check(b):
			print('YES')
			print(a)
			print(b)
		else:
			print('NO')
	else:
		print('NO')

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	s = list(s)
	a = ''
	b = ''
	c1 = 0
	c2 = False
	c = 0
	d = 0
	for i in range(n):
		if s[i] == '1':
			c += 1
	if s[0] == '0' or s[-1] == '0' or c % 2 == 1:
		print('NO')
		d = 1
		continue
	for i in range(n):
		if s[i] == '1':
			if 2 * c1 < c:
				a = a + '('
				b += '('
			else:
				a += ')'
				b += ')'
			c1 += 1
		else:
			if not c2:
				a += '('
				b += ')'
			else:
				a += ')'
				b += '('
			c2 = not c2
	if d == 0:
		print('YES')
		print(a)
		print(b)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
for s in [*open(0)][2::2]:
	N = len(s) - 1
	o = s.count('1')
	if s[0] < '1' or s[-2] < '1':
		print('NO')
		continue
	if o & 1:
		print('NO')
		continue
	n = 0
	a = [0] * N
	b = [0] * N
	c = 1
	for i in range(N):
		if s[i] < '1':
			if c:
				a[i] = ')'
				b[i] = '('
			else:
				a[i] = '('
				b[i] = ')'
			c ^= 1
		else:
			n += 1
			if 2 * n > o:
				a[i] = b[i] = ')'
				n += 1
			else:
				a[i] = b[i] = '('
	print('YES\n' + ''.join(a) + '\n' + ''.join(b))


import math
from collections import defaultdict
from sys import stdin
input = stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	s = input()
	cnt = 0
	for i in s:
		if i == '1':
			cnt += 1
	if s[0] == '0' or s[n - 1] == '0' or cnt % 2 == 1:
		print('NO')
		continue
	k = 0
	(a, b) = ('', '')
	flip = 1
	for i in range(n):
		if s[i] == '1':
			if k * 2 < cnt:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
			k += 1
		elif s[i] == '0':
			if flip:
				a += '('
				b += ')'
			else:
				a += ')'
				b += '('
			flip = 1 - flip
	print('YES')
	print(a)
	print(b)


from sys import stdin
text = stdin.read().splitlines()
t = int(text[0])

def ones(s):
	return len(list(filter(lambda x: x == '1', s)))
for i in range(1, 2 * t + 1, 2):
	n = int(text[i])
	binum = text[i + 1]
	if binum[0] == '0' or binum[-1] == '0':
		print('NO')
		continue
	onecount = ones(binum)
	if onecount % 2 != 0:
		print('NO')
		continue
	a = []
	b = []
	aopens = 0
	bopens = 0
	u = -1
	whatput = 0
	for c in binum:
		if c == '1':
			u += 1
			if u >= onecount / 2:
				aopens -= 1
				bopens -= 1
				a.append(')')
				b.append(')')
			else:
				aopens += 1
				bopens += 1
				a.append('(')
				b.append('(')
		else:
			whatput = 1 - whatput
			if whatput == 0:
				a.append('(')
				b.append(')')
			else:
				a.append(')')
				b.append('(')
	print('YES')
	print(''.join(a))
	print(''.join(b))


def init_array(n):
	arr1d = [0] * n
	return arr1d

def init_array2d(arr_rows, arr_columns):
	arr2d = [[0 for a in range(arr_columns)] for b in range(arr_rows)]
	return arr2d

def print_array2d(arr2d):
	for f in range(len(arr2d)):
		for q in range(len(arr2d[0])):
			print(arr2d[f][q])

def get_array2d_input(arr_rows, arr_columns):
	arr2d = [[0 for f in range(arr_columns)] for q in range(arr_rows)]
	for f in range(arr_rows):
		line = input()
		words = line.split()
		for q in range(arr_columns):
			arr2d[f][q] = int(words[q])
	return arr2d

def solve():
	dummy = 0
testCases = int(input())
for test_case in range(1, testCases + 1):
	line1 = input()
	word1 = line1.split()
	N = int(word1[0])
	s = input()
	cost = 0
	brackets_a = ''
	brackets_b = ''
	stack_a = []
	stack_b = []
	possible = True
	for i in range(N):
		if s[i] == '1':
			if len(stack_a) == 0 or len(stack_b) == 0:
				brackets_a += '('
				brackets_b += '('
				stack_a.append('(')
				stack_b.append('(')
			elif i < N - 1:
				if len(stack_a) == 1 and len(stack_b) == 1:
					if s[i + 1] == '0':
						brackets_a += '('
						brackets_b += '('
						stack_a.append('(')
						stack_b.append('(')
					else:
						if len(stack_a) == 0 or len(stack_b) == 0:
							possible = False
							break
						brackets_a += ')'
						brackets_b += ')'
						stack_a.pop()
						stack_b.pop()
				else:
					if len(stack_a) == 0 or len(stack_b) == 0:
						possible = False
						break
					brackets_a += ')'
					brackets_b += ')'
					stack_a.pop()
					stack_b.pop()
			else:
				if len(stack_a) == 0 or len(stack_b) == 0:
					possible = False
					break
				brackets_a += ')'
				brackets_b += ')'
				stack_a.pop()
				stack_b.pop()
		elif len(stack_a) == 0 and len(stack_b) == 0:
			possible = False
			break
		elif len(stack_a) >= len(stack_b):
			if len(stack_a) == 0:
				possible = False
				break
			brackets_a += ')'
			brackets_b += '('
			stack_a.pop()
			stack_b.append('(')
		else:
			if len(stack_b) == 0:
				possible = False
				break
			brackets_a += '('
			brackets_b += ')'
			stack_b.pop()
			stack_a.append('(')
	ans = ''
	if possible:
		if len(stack_a) == 0 and len(stack_b) == 0:
			ans = 'YES'
		else:
			ans = 'NO'
	else:
		ans = 'NO'
	if ans == 'NO':
		print('NO')
	else:
		print('YES')
		print(brackets_a)
		print(brackets_b)


import array
import math

def main():
	tc = 1
	tc = int(input())
	while tc:
		n = int(input())
		s = input()
		res = True
		cnt = 0
		for i in range(n):
			if s[i] == '0':
				if i == 0 or i == n - 1:
					res = False
					break
				cnt += 1
		if cnt % 2 == 1:
			res = False
		if res:
			(c, cnt1, c1, a, b) = (0, n - cnt, 0, '', '')
			for i in range(n):
				if s[i] == '1':
					c1 += 1
					if c1 <= cnt1 / 2:
						a += '('
						b += '('
					else:
						a += ')'
						b += ')'
				else:
					c += 1
					if c % 2:
						a += '('
						b += ')'
					else:
						a += ')'
						b += '('
			print('YES')
			print(a)
			print(b)
		else:
			print('NO')
		tc -= 1
main()


from bisect import *
import math
from collections import *
from heapq import *
from itertools import *
inf = 10 ** 18
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	s = input()
	if s[0] != '1' or s[-1] != '1' or s.count('1') % 2:
		print('NO')
	else:
		print('YES')
		temp = s.count('1') // 2
		ans = ''
		bns = ''
		cnto = 0
		cntc = 0
		for i in range(n):
			if s[i] == '1':
				if temp:
					ans += '('
					bns += '('
					temp -= 1
					cnto += 1
					cntc += 1
				else:
					ans += ')'
					bns += ')'
					cnto -= 1
					cntc -= 1
			elif cnto < cntc:
				ans += '('
				bns += ')'
				cnto += 1
				cntc -= 1
			else:
				ans += ')'
				bns += '('
				cntc += 1
				cnto -= 1
		print(ans)
		print(bns)


try:

	def solve(n, s):
		add = 0
		for i in s:
			if i == '1':
				add += 1
		if s[0] == '0' or s[n - 1] == '0' or add % 2 == 1:
			print('NO')
			return
		(a, b) = ('', '')
		(c1, c2) = (1, 0)
		for i in s:
			if i == '1':
				if c1 <= add // 2:
					a += '('
					b += '('
				else:
					a += ')'
					b += ')'
				c1 += 1
			else:
				if c2 % 2 == 0:
					a += '('
					b += ')'
				else:
					a += ')'
					b += '('
				c2 += 1
		print('YES')
		print(a)
		print(b)
		return
	t = int(input())
	while t:
		n = int(input())
		s = input()
		solve(n, s)
		t -= 1
except EOFError as e:
	pass


import time
import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import bisect_left, bisect_right
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string, heapq as h
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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 getInt():
	return int(input())

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

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

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

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

def isInt(s):
	return '0' <= s[0] <= '9'

def ceil_(a, b):
	return a // b + (a % b > 0)
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	S = getBin()
	ones = S.count(1)
	if ones % 2:
		print('NO')
		return
	ones //= 2
	curr1 = curr2 = 0
	A = []
	B = []
	one_count = 0
	for i in range(N):
		if S[i] == 1:
			if one_count < ones:
				A.append('(')
				B.append('(')
				curr1 += 1
				curr2 += 1
				one_count += 1
			else:
				A.append(')')
				B.append(')')
				curr1 -= 1
				curr2 -= 1
		elif curr1 < curr2:
			A.append('(')
			B.append(')')
			curr1 += 1
			curr2 -= 1
		else:
			A.append(')')
			B.append('(')
			curr1 -= 1
			curr2 += 1
		if min(curr1, curr2) < 0:
			print('NO')
			return
	if curr1 != 0 or curr2 != 0:
		print('NO')
		return
	print('YES')
	print(''.join(A))
	print(''.join(B))
	return
for _ in range(getInt()):
	solve()


for i in range(int(input())):
	N = int(input())
	s = input()
	zero = 0
	for i in range(N):
		if s[i] == '0':
			zero += 1
	if zero % 2:
		print('NO')
	elif s[0] == '0' or s[-1] == '0':
		print('NO')
	else:
		one = N - zero
		s1 = ''
		s2 = ''
		one_half = one / 2
		flag_0 = 0
		for i in range(N):
			if s[i] == '1' and one_half > 0:
				s1 += '('
				s2 += '('
				one_half -= 1
			elif s[i] == '1' and one_half == 0:
				s1 += ')'
				s2 += ')'
			elif s[i] == '0' and flag_0 == 0:
				s1 += '('
				s2 += ')'
				flag_0 = 1
			elif s[i] == '0' and flag_0 == 1:
				s1 += ')'
				s2 += '('
				flag_0 = 0
		print('YES')
		print(s1)
		print(s2)


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	n = rn()
	s = rs()
	c = s.count('1')
	if s[0] == s[-1] == '1' and c % 2 == 0:
		print('YES')
		a = ''
		b = ''
		turn = 1
		ones = 0
		for i in range(n):
			if s[i] == '0':
				if turn == 1:
					a += '('
					b += ')'
				else:
					a += ')'
					b += '('
				turn *= -1
			elif ones < c // 2:
				a += '('
				b += '('
				ones += 1
			else:
				a += ')'
				b += ')'
		print(a)
		print(b)
	else:
		print('NO')


def ss(n, s):
	a = ''
	b = ''
	x = 0
	y = 0
	p = s.count('1')
	q = 0
	f = 0
	for i in s:
		if i == '1':
			p -= 1
			q += 1
			if q > p:
				a += ')'
				b += ')'
				x -= 1
				y -= 1
			else:
				a += '('
				b += '('
				x += 1
				y += 1
		elif f:
			f = 0
			a += ')'
			b += '('
			x -= 1
			y += 1
		else:
			f = 1
			a += '('
			b += ')'
			x += 1
			y -= 1
		if x < 0 or y < 0:
			return [-1]
	if x == 0 and y == 0:
		return [a, b]
	else:
		return [-1]
for _ in range(int(input())):
	n = int(input())
	s = str(input())
	n = len(s)
	if n % 2 == 1:
		print('NO')
	else:
		ans = ss(n, s)
		if ans == [-1]:
			print('NO')
		else:
			print('YES')
			print(ans[0])
			print(ans[1])


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = input()
		ans1 = ['*'] * n
		ans2 = ['*'] * n
		cnt1 = 0
		for elem in a:
			if elem == '1':
				cnt1 += 1
		if cnt1 % 2:
			print('NO')
			continue
		cntPlus = cnt1 // 2
		tmp = 0
		for i in range(n):
			if a[i] == '1':
				if tmp < cntPlus:
					ans1[i] = '('
					ans2[i] = '('
					tmp += 1
				else:
					ans1[i] = ')'
					ans2[i] = ')'
		count1 = 0
		count2 = 0
		flag = True
		for i in range(n):
			if a[i] == '1':
				if ans1[i] == '(':
					count1 += 1
					count2 += 1
				else:
					count1 -= 1
					count2 -= 1
					if count1 < 0 or count2 < 0:
						flag = False
						break
			elif count1 >= count2:
				ans1[i] = ')'
				ans2[i] = '('
				count1 -= 1
				count2 += 1
				if count1 < 0:
					flag = False
					break
			else:
				ans1[i] = '('
				ans2[i] = ')'
				count1 += 1
				count2 -= 1
				if count2 < 0:
					flag = False
					break
		if flag:
			print('YES')
			print(''.join(ans1))
			print(''.join(ans2))
		else:
			print('NO')
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')
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	(one, zero) = (s.count('1'), s.count('0'))
	if s[0] == '0' or s[n - 1] == '0' or zero % 2 or n % 2:
		print('NO')
		continue
	(curr_one, curr_zero) = (0, 0)
	a = ''
	for i in range(n):
		if s[i] == '1':
			if curr_one < one // 2:
				a += '('
			else:
				a += ')'
			curr_one += 1
		else:
			if curr_zero % 2:
				a += ')'
			else:
				a += '('
			curr_zero += 1
	b = ''
	for i in range(n):
		if s[i] == '1':
			b += a[i]
		elif a[i] == '(':
			b += ')'
		else:
			b += '('
	print('YES')
	print(a)
	print(b)


from copy import deepcopy
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	count_0 = s.count('0')
	if count_0 % 2 != 0:
		print('NO')
	elif count_0 == 0:
		print('YES')
		print('(' * (n // 2) + ')' * (n // 2))
		print('(' * (n // 2) + ')' * (n // 2))
	elif s[0] == '0' or s[-1] == '0':
		print('NO')
	else:
		count_1 = n - count_0
		ans = ['0' for _ in range(n)]
		counter = 0
		for i in range(0, n):
			if s[i] == '1':
				if counter < count_1 // 2:
					ans[i] = '('
				else:
					ans[i] = ')'
				counter += 1
		ans_2 = deepcopy(ans)
		(x, y) = ('(', ')')
		for i in range(0, n):
			if s[i] == '0':
				ans[i] = x
				ans_2[i] = y
				(x, y) = (y, x)
		print('YES')
		print(''.join(ans))
		print(''.join(ans_2))


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	cnt1 = s.count('1')
	cnt0 = n - cnt1
	a = []
	b = []
	if cnt1 % 2 == 0 and cnt0 % 2 == 0 and (s[0] == s[-1] == '1'):
		j = 0
		pnt = 0
		flip = 0
		while pnt < cnt1 // 2:
			if s[j] == '1':
				a.append('(')
				b.append('(')
				pnt += 1
			elif flip:
				a.append(')')
				b.append('(')
				flip = 0
			else:
				a.append('(')
				b.append(')')
				flip = 1
			j += 1
		while pnt < cnt1:
			if s[j] == '1':
				a.append(')')
				b.append(')')
				pnt += 1
			elif flip:
				a.append(')')
				b.append('(')
				flip = 0
			else:
				a.append('(')
				b.append(')')
				flip = 1
			j += 1
		print('YES')
		print(''.join(a))
		print(''.join(b))
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	a = []
	b = []
	count1 = 0
	for i in range(n):
		if s[i] == '1':
			count1 += 1
	count0 = n - count1
	if count0 % 2:
		print('NO')
		continue
	leftbr0 = count0 // 2
	rightbr0 = count0 // 2
	leftbr1 = n // 2 - leftbr0
	score = 0
	stack = []
	for i in range(n):
		if s[i] == '1':
			if leftbr1:
				a.append('(')
				score += 1
				leftbr1 -= 1
			else:
				a.append(')')
				score -= 1
				if score < 0 and stack:
					rightbr0 += 1
					score += 2
					k = stack.pop()
					a[k] = '('
		elif rightbr0 and score > 0:
			a.append(')')
			score -= 1
			rightbr0 -= 1
			stack.append(i)
		else:
			a.append('(')
			score += 1
	b = []
	for i in range(n):
		if s[i] == '1':
			b.append(a[i])
		elif a[i] == '(':
			b.append(')')
		else:
			b.append('(')
	score1 = 0
	score2 = 0
	flag = 0
	for i in range(n):
		if a[i] == '(':
			score1 += 1
		else:
			score1 -= 1
		if b[i] == '(':
			score2 += 1
		else:
			score2 -= 1
		if score1 < 0 or score2 < 0:
			flag = 1
			break
	if flag or score1 != 0 or score2 != 0:
		print('NO')
	else:
		print('YES')
		print(''.join(a))
		print(''.join(b))


import sys
for _ in range(int(input())):
	n = int(input())
	s = sys.stdin.readline().rstrip()
	one = s.count('1')
	if s[0] == s[-1] == '1' and one % 2 == 0:
		a = []
		b = []
		one //= 2
		flag = 0
		for i in s:
			if i == '0':
				a.append(['(', ')'][flag % 2])
				b.append([')', '('][flag % 2])
				flag += 1
			elif one > 0:
				a.append('(')
				b.append('(')
				one -= 1
			else:
				a.append(')')
				b.append(')')
		print('YES')
		print(''.join(a))
		print(''.join(b))
	else:
		print('NO')


t = int(input())
for t1 in range(0, t):
	n = int(input())
	s = input()
	if s[0] == '0' or s[-1] == '0':
		print('NO')
	else:
		same = []
		diff = []
		for i in range(0, n):
			if s[i] == '1':
				same.append(i)
			else:
				diff.append(i)
		ans1 = list(s)
		ans2 = list(s)
		if len(diff) % 2 == 1:
			print('NO')
		else:
			flag = 1
			for i in diff:
				if flag == 1:
					ans1[i] = ')'
					ans2[i] = '('
				else:
					ans1[i] = '('
					ans2[i] = ')'
				flag = (flag + 1) % 2
			start = 0
			end = len(same) - 1
			while start < end:
				xx = same[start]
				yy = same[end]
				ans1[xx] = '('
				ans2[xx] = '('
				ans1[yy] = ')'
				ans2[yy] = ')'
				start += 1
				end -= 1
			print('YES')
			print(''.join(ans1))
			print(''.join(ans2))


for s in [*open(0)][2::2]:
	N = len(s) - 1
	o = s.count('1')
	if s[0] < '1' or s[-2] < '1':
		print('NO')
		continue
	if o & 1:
		print('NO')
		continue
	n = 0
	a = [0] * N
	b = [0] * N
	c = 1
	for i in range(N):
		if s[i] < '1':
			if c:
				a[i] = ')'
				b[i] = '('
			else:
				a[i] = '('
				b[i] = ')'
			c ^= 1
		else:
			n += 1
			if 2 * n > o:
				a[i] = b[i] = ')'
				n += 1
			else:
				a[i] = b[i] = '('
	print('YES\n' + ''.join(a) + '\n' + ''.join(b))


T = int(input())
for ts in range(T):
	N = int(input())
	s = input()
	if s[0] == '0' or s[-1] == '0':
		print('NO')
		continue
	a = ['(']
	b = ['(']
	ca = 1
	cb = 1
	for i in range(1, N - 1):
		if s[i] == '1':
			if ca == 0 or cb == 0:
				a.append('(')
				b.append('(')
				ca += 1
				cb += 1
			elif ca == cb == 1:
				if s[i + 1] == '1':
					a.append(')')
					b.append(')')
					ca -= 1
					cb -= 1
				else:
					a.append('(')
					b.append('(')
					ca += 1
					cb += 1
			else:
				a.append(')')
				b.append(')')
				ca -= 1
				cb -= 1
		elif ca == 0:
			a.append('(')
			b.append(')')
			ca += 1
			cb -= 1
		elif cb == 0:
			a.append(')')
			b.append('(')
			ca -= 1
			cb += 1
		elif ca > cb:
			a.append(')')
			b.append('(')
			ca -= 1
			cb += 1
		else:
			a.append('(')
			b.append(')')
			ca += 1
			cb -= 1
	a.append(')')
	b.append(')')
	ca -= 1
	cb -= 1
	if ca == cb == 0:
		print('YES')
		print(''.join(a))
		print(''.join(b))
	else:
		print('NO')


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	S = input().strip()
	l = S.count('1')
	o = S.count('0')
	if l % 2 == 1:
		print('NO')
		return
	if S[0] == '0' or S[-1] == '0':
		print('NO')
		return
	print('YES')
	cnt_o = 0
	cnt_l = 0
	T1 = []
	T2 = []
	for s in S:
		if s == '1':
			if cnt_l < l // 2:
				T1.append('(')
				T2.append('(')
			else:
				T1.append(')')
				T2.append(')')
			cnt_l += 1
		else:
			cnt_o += 1
			if cnt_o % 2 == 0:
				T1.append('(')
				T2.append(')')
			else:
				T1.append(')')
				T2.append('(')
	print(''.join(T1))
	print(''.join(T2))
for _ in range(int(input())):
	main()


def divisors(M):
	d = []
	i = 1
	while M >= i ** 2:
		if M % i == 0:
			d.append(i)
			if i ** 2 != M:
				d.append(M // i)
		i = i + 1
	return d

def popcount(x):
	x = x - (x >> 1 & 1431655765)
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x = x + (x >> 8)
	x = x + (x >> 16)
	return x & 127

def eratosthenes(n):
	res = [0 for i in range(n + 1)]
	prime = set([])
	for i in range(2, n + 1):
		if not res[i]:
			prime.add(i)
			for j in range(1, n // i + 1):
				res[i * j] = 1
	return prime

def factorization(n):
	res = []
	for p in prime:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
	if n != 1:
		res.append(n)
	return res

def euler_phi(n):
	res = n
	for x in range(2, n + 1):
		if x ** 2 > n:
			break
		if n % x == 0:
			res = res // x * (x - 1)
			while n % x == 0:
				n //= x
	if n != 1:
		res = res // n * (n - 1)
	return res

def ind(b, n):
	res = 0
	while n % b == 0:
		res += 1
		n //= b
	return res

def isPrimeMR(n):
	d = n - 1
	d = d // (d & -d)
	L = [2, 3, 5, 7, 11, 13, 17]
	for a in L:
		t = d
		y = pow(a, t, n)
		if y == 1:
			continue
		while y != n - 1:
			y = y * y % n
			if y == 1 or t == n - 1:
				return 0
			t <<= 1
	return 1

def findFactorRho(n):
	from math import gcd
	m = 1 << n.bit_length() // 8
	for c in range(1, 99):
		f = lambda x: (x * x + c) % n
		(y, r, q, g) = (2, 1, 1, 1)
		while g == 1:
			x = y
			for i in range(r):
				y = f(y)
			k = 0
			while k < r and g == 1:
				ys = y
				for i in range(min(m, r - k)):
					y = f(y)
					q = q * abs(x - y) % n
				g = gcd(q, n)
				k += m
			r <<= 1
		if g == n:
			g = 1
			while g == 1:
				ys = f(ys)
				g = gcd(abs(x - ys), n)
		if g < n:
			if isPrimeMR(g):
				return g
			elif isPrimeMR(n // g):
				return n // g
			return findFactorRho(g)

def primeFactor(n):
	i = 2
	ret = {}
	rhoFlg = 0
	while i * i <= n:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
		if k:
			ret[i] = k
		i += 1 + i % 2
		if i == 101 and n >= 2 ** 20:
			while n > 1:
				if isPrimeMR(n):
					(ret[n], n) = (1, 1)
				else:
					rhoFlg = 1
					j = findFactorRho(n)
					k = 0
					while n % j == 0:
						n //= j
						k += 1
					ret[j] = k
	if n > 1:
		ret[n] = 1
	if rhoFlg:
		ret = {x: ret[x] for x in sorted(ret)}
	return ret

def divisors(n):
	res = [1]
	prime = primeFactor(n)
	for p in prime:
		newres = []
		for d in res:
			for j in range(prime[p] + 1):
				newres.append(d * p ** j)
		res = newres
	res.sort()
	return res

def xorfactorial(num):
	if num == 0:
		return 0
	elif num == 1:
		return 1
	elif num == 2:
		return 3
	elif num == 3:
		return 0
	else:
		x = baseorder(num)
		return 2 ** x * ((num - 2 ** x + 1) % 2) + function(num - 2 ** x)

def xorconv(n, X, Y):
	if n == 0:
		res = [X[0] * Y[0] % mod]
		return res
	x = [X[i] + X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	y = [Y[i] + Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	z = [X[i] - X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	w = [Y[i] - Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	res1 = xorconv(n - 1, x, y)
	res2 = xorconv(n - 1, z, w)
	former = [(res1[i] + res2[i]) * inv for i in range(2 ** (n - 1))]
	latter = [(res1[i] - res2[i]) * inv for i in range(2 ** (n - 1))]
	former = list(map(lambda x: x % mod, former))
	latter = list(map(lambda x: x % mod, latter))
	return former + latter

def merge_sort(A, B):
	(pos_A, pos_B) = (0, 0)
	(n, m) = (len(A), len(B))
	res = []
	while pos_A < n and pos_B < m:
		(a, b) = (A[pos_A], B[pos_B])
		if a < b:
			res.append(a)
			pos_A += 1
		else:
			res.append(b)
			pos_B += 1
	res += A[pos_A:]
	res += B[pos_B:]
	return res

class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)

class WeightedUnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for i in range(N)]
		self.val = [0 for i in range(N)]
		self.flag = True
		self.edge = [[] for i in range(N)]

	def dfs(self, v, pv):
		stack = [(v, pv)]
		new_parent = self.parent[pv]
		while stack:
			(v, pv) = stack.pop()
			self.parent[v] = new_parent
			for (nv, w) in self.edge[v]:
				if nv != pv:
					self.val[nv] = self.val[v] + w
					stack.append((nv, v))

	def unite(self, x, y, w):
		if not self.flag:
			return
		if self.parent[x] == self.parent[y]:
			self.flag = self.val[x] - self.val[y] == w
			return
		if self.size[self.parent[x]] > self.size[self.parent[y]]:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[x] += self.size[y]
			self.val[y] = self.val[x] - w
			self.dfs(y, x)
		else:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[y] += self.size[x]
			self.val[x] = self.val[y] + w
			self.dfs(x, y)

class Dijkstra:

	class Edge:

		def __init__(self, _to, _cost):
			self.to = _to
			self.cost = _cost

	def __init__(self, V):
		self.G = [[] for i in range(V)]
		self._E = 0
		self._V = V

	@property
	def E(self):
		return self._E

	@property
	def V(self):
		return self._V

	def add_edge(self, _from, _to, _cost):
		self.G[_from].append(self.Edge(_to, _cost))
		self._E += 1

	def shortest_path(self, s):
		import heapq
		que = []
		d = [10 ** 15] * self.V
		d[s] = 0
		heapq.heappush(que, (0, s))
		while len(que) != 0:
			(cost, v) = heapq.heappop(que)
			if d[v] < cost:
				continue
			for i in range(len(self.G[v])):
				e = self.G[v][i]
				if d[e.to] > d[v] + e.cost:
					d[e.to] = d[v] + e.cost
					heapq.heappush(que, (d[e.to], e.to))
		return d

def Z_algorithm(s):
	N = len(s)
	Z_alg = [0] * N
	Z_alg[0] = N
	i = 1
	j = 0
	while i < N:
		while i + j < N and s[j] == s[i + j]:
			j += 1
		Z_alg[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < N and k + Z_alg[k] < j:
			Z_alg[i + k] = Z_alg[k]
			k += 1
		i += k
		j -= k
	return Z_alg

class BIT:

	def __init__(self, n, mod=0):
		self.BIT = [0] * (n + 1)
		self.num = n
		self.mod = mod

	def query(self, idx):
		res_sum = 0
		mod = self.mod
		while idx > 0:
			res_sum += self.BIT[idx]
			if mod:
				res_sum %= mod
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		mod = self.mod
		while idx <= self.num:
			self.BIT[idx] += x
			if mod:
				self.BIT[idx] %= mod
			idx += idx & -idx
		return

class dancinglink:

	def __init__(self, n, debug=False):
		self.n = n
		self.debug = debug
		self._left = [i - 1 for i in range(n)]
		self._right = [i + 1 for i in range(n)]
		self.exist = [True for i in range(n)]

	def pop(self, k):
		if self.debug:
			assert self.exist[k]
		L = self._left[k]
		R = self._right[k]
		if L != -1:
			if R != self.n:
				(self._right[L], self._left[R]) = (R, L)
			else:
				self._right[L] = self.n
		elif R != self.n:
			self._left[R] = -1
		self.exist[k] = False

	def left(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._left[res]
			if res == -1:
				break
			k -= 1
		return res

	def right(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._right[res]
			if res == self.n:
				break
			k -= 1
		return res

class SparseTable:

	def __init__(self, A, merge_func, ide_ele):
		N = len(A)
		n = N.bit_length()
		self.table = [[ide_ele for i in range(n)] for i in range(N)]
		self.merge_func = merge_func
		for i in range(N):
			self.table[i][0] = A[i]
		for j in range(1, n):
			for i in range(0, N - 2 ** j + 1):
				f = self.table[i][j - 1]
				s = self.table[i + 2 ** (j - 1)][j - 1]
				self.table[i][j] = self.merge_func(f, s)

	def query(self, s, t):
		b = t - s + 1
		m = b.bit_length() - 1
		return self.merge_func(self.table[s][m], self.table[t - 2 ** m + 1][m])

class BinaryTrie:

	class node:

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

	def __init__(self):
		self.root = self.node(-10 ** 15)

	def append(self, key, val):
		pos = self.root
		for i in range(29, -1, -1):
			pos.max = max(pos.max, val)
			if key >> i & 1:
				if pos.right is None:
					pos.right = self.node(val)
					pos = pos.right
				else:
					pos = pos.right
			elif pos.left is None:
				pos.left = self.node(val)
				pos = pos.left
			else:
				pos = pos.left
		pos.max = max(pos.max, val)

	def search(self, M, xor):
		res = -10 ** 15
		pos = self.root
		for i in range(29, -1, -1):
			if pos is None:
				break
			if M >> i & 1:
				if xor >> i & 1:
					if pos.right:
						res = max(res, pos.right.max)
					pos = pos.left
				else:
					if pos.left:
						res = max(res, pos.left.max)
					pos = pos.right
			elif xor >> i & 1:
				pos = pos.right
			else:
				pos = pos.left
		if pos:
			res = max(res, pos.max)
		return res

def solveequation(edge, ans, n, m):
	x = [0] * m
	used = [False] * n
	for v in range(n):
		if used[v]:
			continue
		y = dfs(v)
		if y != 0:
			return False
	return x

	def dfs(v):
		used[v] = True
		r = ans[v]
		for (to, dire, id) in edge[v]:
			if used[to]:
				continue
			y = dfs(to)
			if dire == -1:
				x[id] = y
			else:
				x[id] = -y
			r += y
		return r

class Matrix:
	mod = 10 ** 9 + 7

	def set_mod(m):
		Matrix.mod = m

	def __init__(self, L):
		self.row = len(L)
		self.column = len(L[0])
		self._matrix = L
		for i in range(self.row):
			for j in range(self.column):
				self._matrix[i][j] %= Matrix.mod

	def __getitem__(self, item):
		if type(item) == int:
			raise IndexError('you must specific row and column')
		elif len(item) != 2:
			raise IndexError('you must specific row and column')
		(i, j) = item
		return self._matrix[i][j]

	def __setitem__(self, item, val):
		if type(item) == int:
			raise IndexError('you must specific row and column')
		elif len(item) != 2:
			raise IndexError('you must specific row and column')
		(i, j) = item
		self._matrix[i][j] = val

	def __add__(self, other):
		if (self.row, self.column) != (other.row, other.column):
			raise SizeError('sizes of matrixes are different')
		res = [[0 for j in range(self.column)] for i in range(self.row)]
		for i in range(self.row):
			for j in range(self.column):
				res[i][j] = self._matrix[i][j] + other._matrix[i][j]
				res[i][j] %= Matrix.mod
		return Matrix(res)

	def __sub__(self, other):
		if (self.row, self.column) != (other.row, other.column):
			raise SizeError('sizes of matrixes are different')
		res = [[0 for j in range(self.column)] for i in range(self.row)]
		for i in range(self.row):
			for j in range(self.column):
				res[i][j] = self._matrix[i][j] - other._matrix[i][j]
				res[i][j] %= Matrix.mod
		return Matrix(res)

	def __mul__(self, other):
		if type(other) != int:
			if self.column != other.row:
				raise SizeError('sizes of matrixes are different')
			res = [[0 for j in range(other.column)] for i in range(self.row)]
			for i in range(self.row):
				for j in range(other.column):
					temp = 0
					for k in range(self.column):
						temp += self._matrix[i][k] * other._matrix[k][j]
					res[i][j] = temp % Matrix.mod
			return Matrix(res)
		else:
			n = other
			res = [[n * self._matrix[i][j] % Matrix.mod for j in range(self.column)] for i in range(self.row)]
			return Matrix(res)

	def __pow__(self, m):
		if self.column != self.row:
			raise MatrixPowError('the size of row must be the same as that of column')
		n = self.row
		res = Matrix([[int(i == j) for i in range(n)] for j in range(n)])
		while m:
			if m % 2 == 1:
				res = res * self
			self = self * self
			m //= 2
		return res

	def __str__(self):
		res = []
		for i in range(self.row):
			for j in range(self.column):
				res.append(str(self._matrix[i][j]))
				res.append(' ')
			res.append('\n')
		res = res[:len(res) - 1]
		return ''.join(res)
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import log, gcd
input = lambda : sys.stdin.readline().rstrip()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
for _ in range(int(input())):
	n = int(input())
	s = input()
	same = s.count('1')
	diff = s.count('0')
	if same % 2 or diff % 2:
		print('NO')
		continue
	rest_same = same // 2
	next = '('
	a = []
	b = []
	(A, B) = (0, 0)
	for i in range(n):
		if s[i] == '1':
			if rest_same:
				a.append('(')
				b.append('(')
				A += 1
				B += 1
				rest_same -= 1
			else:
				a.append(')')
				b.append(')')
				A -= 1
				B -= 1
			if A < 0 or B < 0:
				print('NO')
				break
		else:
			if next == '(':
				a.append('(')
				b.append(')')
				next = ')'
				A += 1
				B -= 1
			else:
				a.append(')')
				b.append('(')
				next = '('
				A -= 1
				B += 1
			if A < 0 or B < 0:
				print('NO')
				break
	else:
		print('YES')
		print(''.join(a))
		print(''.join(b))


def answer(s):
	count1 = 0
	count = 0
	count0 = 0
	a = ''
	b = ''
	if s[0] == '0' or s[-1] == '0':
		return ['NO']
	for i in s:
		if i == '1':
			count1 += 1
		else:
			count0 += 1
	if count1 % 2 != 0 or count1 == 0 or len(s) % 2 != 0:
		return ['NO']
	var = 0
	for i in s:
		if i == '1':
			if count < count1 // 2:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
			count += 1
		elif var == 0:
			a += ')'
			b += '('
			var = 1
		else:
			a += '('
			b += ')'
			var = 0
	return ['YES', a, b]
t = int(input())
for w in range(t):
	n = int(input())
	s = input()
	result = answer(s)
	if result[0] == 'NO':
		print('NO')
	else:
		print('YES')
		print(result[1])
		print(result[2])


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	s = stdin.readline(n)
	stdin.readline(1)
	if s[0] == '0' or s[n - 1] == '0':
		stdout.write('NO\n')
		continue
	a = []
	b = []
	(va, vb) = (0, 0)
	for i in range(n):
		if s[i] == '1':
			if va + vb < 4:
				va += 1
				vb += 1
				a.append('(')
				b.append('(')
			else:
				va -= 1
				vb -= 1
				a.append(')')
				b.append(')')
		elif s[i] == '0':
			if va <= 1:
				va += 1
				vb -= 1
				a.append('(')
				b.append(')')
			else:
				va -= 1
				vb += 1
				a.append(')')
				b.append('(')
	if not va == vb == 2:
		stdout.write('NO\n')
	else:
		a[-1] = ')'
		b[-1] = ')'
		stdout.write('YES\n')
		stdout.write(''.join(a))
		stdout.write('\n')
		stdout.write(''.join(b))
		stdout.write('\n')


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

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

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

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

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = inp()
	s = st()
	if n & 1 or s[0] != '1' or s[-1] != '1':
		pr('NO')
		return
	a = 0
	A = []
	B = []
	one = []
	zero = []
	for i in range(n):
		if s[i] == '1':
			one.append(i)
			a += 1
		else:
			zero.append(i)
		A.append(0)
		B.append(0)
	if a % 2:
		pr('NO')
		return
	for i in range(a):
		if i < a // 2:
			A[one[i]] = '('
			B[one[i]] = '('
		else:
			A[one[i]] = ')'
			B[one[i]] = ')'
	b = n - a
	for i in range(b):
		if i % 2 == 0:
			A[zero[i]] = '('
			B[zero[i]] = ')'
		else:
			A[zero[i]] = ')'
			B[zero[i]] = '('
	pr('YES')
	print(*A, sep='')
	print(*B, sep='')
for _ in range(inp()):
	solve()


import sys, io, os
try:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
except:
	input = lambda : sys.stdin.readline().encode()
out = []
t = int(input())
for _ in range(t):
	n = int(input())
	s = input().strip()
	c1 = 0
	for c in s:
		if c == 49:
			c1 += 1
	if c1 % 2 == 1:
		out.append('NO')
		continue
	s1 = []
	s2 = []
	ac = 0
	bc = 0
	works = True
	r1 = c1 // 2
	toggle = 0
	for c in s:
		if c == 49:
			if r1:
				s1.append('(')
				s2.append('(')
				ac += 1
				bc += 1
				r1 -= 1
			else:
				s1.append(')')
				s2.append(')')
				ac -= 1
				bc -= 1
		else:
			if toggle:
				s1.append(')')
				s2.append('(')
				ac += 1
				bc -= 1
			else:
				s1.append('(')
				s2.append(')')
				ac -= 1
				bc += 1
			toggle ^= 1
		if ac < 0 or bc < 0:
			works = False
			break
	if works:
		assert ac == 0 and bc == 0
		out.append('YES')
		out.append(''.join(s1))
		out.append(''.join(s2))
	else:
		out.append('NO')
print('\n'.join(out))


from collections import Counter
from itertools import accumulate
from bisect import bisect_left
import sys
input = sys.stdin.readline
inf = 100000000000000000
mod = 998244353
for CASES in range(int(input())):
	n = int(input())
	S = input().strip()
	C = Counter(S)
	if C['1'] % 2 != 0:
		print('NO')
		continue
	elif S[0] != '1' or S[-1] != '1':
		print('NO')
		continue
	A = [''] * len(S)
	B = [''] * len(S)
	bian = 0
	numkuo = 0
	for (i, s) in enumerate(S):
		if s == '1':
			numkuo += 1
			if numkuo <= C['1'] // 2:
				A[i] = '('
				B[i] = '('
			else:
				A[i] = ')'
				B[i] = ')'
		else:
			bian ^= 1
			if bian == 1:
				A[i] = '('
				B[i] = ')'
			else:
				A[i] = ')'
				B[i] = '('
	print('YES')
	print(''.join(A))
	print(''.join(B))


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s[0] == '0' or s[-1] == '0' or s.count('1') % 2 == 1:
		print('NO')
	else:
		ok = True
		(a, b) = ([0] * n, [0] * n)
		i = 1
		last = '('
		k = s.count('1') // 2
		for i in range(n):
			if k == 0:
				last = ')'
			if s[i] == '1':
				a[i] = last
				b[i] = last
				k -= 1
		last = '('
		l2 = ')'
		for i in range(n):
			if s[i] == '0':
				a[i] = last
				b[i] = l2
				(l2, last) = (last, l2)
		print('YES')
		print(''.join(a))
		print(''.join(b))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	cnt = 0
	for i in s:
		cnt += i == '1'
	if s[0] == '0' or s[n - 1] == '0' or cnt % 2 == 1:
		print('NO')
		continue
	k = 0
	(a, b) = ('', '')
	flip = False
	for i in range(n):
		if s[i] == '1':
			if k * 2 < cnt:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
			k += 1
		else:
			if flip:
				a += ')'
				b += '('
			else:
				a += '('
				b += ')'
			flip = not flip
	print('YES')
	print(a)
	print(b)


def isvalid(s):
	c = 0
	for i in range(len(s)):
		if s[i] == '(':
			c += 1
		else:
			c -= 1
		if c < 0:
			return False
	if c == 0:
		return True
	return False
t = int(input())
while t != 0:
	n = int(input())
	s = input()
	if n & 1 == 1:
		print('NO')
	else:
		zero = 0
		for i in range(n):
			if s[i] == '0':
				zero += 1
		if zero % 2 == 1:
			print('NO')
		else:
			count = (n - zero) // 2
			s1 = ''
			s2 = ''
			f = 0
			for i in range(n):
				if s[i] == '1' and count > 0:
					s1 += '('
					s2 += '('
					count -= 1
				elif s[i] == '1':
					s1 += ')'
					s2 += ')'
				if s[i] == '0' and f == 0:
					s1 += '('
					s2 += ')'
					f = 1
				elif s[i] == '0':
					s1 += ')'
					s2 += '('
					f = 0
			if isvalid(s1) and isvalid(s2):
				print('YES')
				print(s1)
				print(s2)
			else:
				print('NO')
	t -= 1


import sys
lines = sys.stdin.readlines()
lineidx = 0

def readLine():
	global lineidx
	s = lines[lineidx].strip()
	lineidx += 1
	return s
t = int(readLine())
for testcase in range(t):
	n = int(readLine())
	s = readLine()
	cntone = s.count('1')
	cntzero = s.count('0')
	if cntone % 2 != 0 or cntzero % 2 != 0:
		print('NO')
		continue
	cntone /= 2
	a = ['x'] * n
	b = ['x'] * n
	bala = balb = 0
	for i in range(n):
		if s[i] == '1':
			if cntone > 0:
				cntone -= 1
				a[i] = b[i] = '('
			else:
				a[i] = b[i] = ')'
		else:
			if cntzero % 2 == 0:
				a[i] = '('
				b[i] = ')'
			else:
				a[i] = ')'
				b[i] = '('
			cntzero -= 1
		if a[i] == '(':
			bala += 1
		else:
			bala -= 1
		if b[i] == '(':
			balb += 1
		else:
			balb -= 1
		if bala < 0 or balb < 0:
			break
	if bala != 0 or balb != 0:
		print('NO')
	else:
		print('YES')
		print(''.join(a))
		print(''.join(b))


import sys
from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	s = stdin.readline()[:-1]
	S = s
	if n % 2 == 1:
		print('NO')
		continue
	a = []
	b = []
	at = 0
	bt = 0
	znum = 0
	onum = 0
	for i in range(n):
		if s[i] == '1':
			onum += 1
		else:
			znum += 1
	if znum % 2 == 1:
		print('NO')
		continue
	nz = 0
	no = 0
	at = 0
	bt = 0
	a = []
	b = []
	ans = 'YES'
	for i in range(n):
		if S[i] == '1':
			no += 1
			if no * 2 > onum:
				a.append(')')
				b.append(')')
				at -= 1
				bt -= 1
			else:
				a.append('(')
				b.append('(')
				at += 1
				bt += 1
		else:
			if nz % 2 == 0:
				a.append('(')
				b.append(')')
				at += 1
				bt -= 1
			else:
				a.append(')')
				b.append('(')
				at -= 1
				bt += 1
			nz += 1
		if at < 0 or bt < 0:
			ans = 'NO'
			break
	if at != 0 or bt != 0 or ans == 'NO':
		print('NO')
	else:
		print('YES')
		print(''.join(a))
		print(''.join(b))


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

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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 ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for testcase in range(t):
	n = ri()
	ss = input()
	num_ones = ss.count('1')
	num_zeros = ss.count('0')
	if num_zeros % 2 != 0 or num_ones % 2 != 0:
		print('NO')
		continue
	if ss[0] != '1' or ss[-1] != '1':
		print('NO')
		continue
	count = -1
	count1 = -1
	ans1 = [''] * len(ss)
	ans2 = [''] * len(ss)
	for i in range(len(ss)):
		if ss[i] == '1':
			count1 += 1
			if count1 < num_ones // 2:
				ans2[i] = '('
				ans1[i] = '('
			else:
				ans2[i] = ')'
				ans1[i] = ')'
		else:
			count += 1
			if count % 2:
				ans1[i] = ')'
				ans2[i] = '('
			else:
				ans1[i] = '('
				ans2[i] = ')'
	print('YES')
	print(''.join(ans1))
	print(''.join(ans2))


import sys
import math
from math import factorial, inf, gcd
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
sys.setrecursionlimit(10 ** 5)

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

def g(s):
	c = 0
	for i in s:
		if i == '(':
			c += 1
		elif c <= 0:
			return False
		else:
			c -= 1
	return c == 0
ti = 1
ti = int(input())
for ii in range(ti):
	n = int(input())
	a = input()
	(l1, l2) = (n // 2, n // 2)
	s1 = [' '] * n
	s2 = [' '] * n
	f = True
	for i in range(n):
		if a[i] == '0':
			if f:
				s1[i] = '('
				s2[i] = ')'
				l1 -= 1
			else:
				s2[i] = '('
				s1[i] = ')'
				l2 -= 1
			f = not f
	if l1 != l2:
		print('NO')
		continue
	for i in range(n):
		if a[i] == '1':
			if l1 > 0:
				s1[i] = s2[i] = '('
				l1 -= 1
			else:
				s1[i] = s2[i] = ')'
	if g(s1) and g(s2):
		print('YES')
		print(''.join(s1))
		print(''.join(s2))
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	string = input()
	a = ''
	b = ''
	oneCount = string.count('1')
	zeroCount = string.count('0')
	if string[0] == string[-1] == '1':
		if oneCount % 2 == 0 and zeroCount % 2 == 0:
			one = 0
			zero = 0
			for i in string:
				if i == '1':
					one += 1
					if oneCount // 2 >= one:
						a += '('
						b += '('
					else:
						a += ')'
						b += ')'
				elif i == '0':
					zero += 1
					if zero % 2 == 0:
						a += '('
						b += ')'
					else:
						a += ')'
						b += '('
			print('YES')
			print(a)
			print(b)
		else:
			print('NO')
	else:
		print('NO')


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		N = int(input())
		S = input().rstrip('\n')
		A = []
		B = []
		cnt_A = 0
		cnt_B = 0
		num_1 = S.count('1')
		if num_1 & 1:
			print('NO')
			continue
		cnt_1 = 0
		flg = 0
		for (i, s) in enumerate(S):
			if s == '1':
				if cnt_1 < num_1 // 2:
					A.append('(')
					B.append('(')
					cnt_A += 1
					cnt_B += 1
				else:
					A.append(')')
					B.append(')')
					cnt_A -= 1
					cnt_B -= 1
				cnt_1 += 1
			else:
				if flg:
					A.append(')')
					cnt_A -= 1
					B.append('(')
					cnt_B += 1
				else:
					A.append('(')
					cnt_A += 1
					B.append(')')
					cnt_B -= 1
				flg ^= 1
			if cnt_A < 0 or cnt_B < 0:
				break
		if cnt_A == cnt_B == 0:
			print('YES')
			print(''.join(A))
			print(''.join(B))
		else:
			print('NO')
main()


import sys, math

def compute(s, inv=True):
	a = b = ''
	count_1 = s.count('1')
	count_0 = s.count('0')
	if s[0] == '0' or s[-1] == '0' or count_0 & 1 or count_1 & 1:
		return
	half_1 = count_1 // 2
	i_0 = i_1 = 0
	for (i, c) in enumerate(s):
		if c == '1':
			a += '()'[i_1 >= half_1]
			b += '()'[i_1 >= half_1]
			i_1 += 1
		else:
			a += '()'[i_0 & 1]
			b += ')('[i_0 & 1]
			i_0 += 1
	return (a, b)
for _ in '_' * int(input()):
	if int(input()) & 1:
		input()
		print('NO')
	result = compute(input())
	if result:
		print('YES', *result, sep='\n')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = ''
	b = ''
	c1 = s.count('1')
	c0 = s.count('0')
	if c1 % 2 != 0 or c0 % 2 != 0 or s[0] != '1' or (s[-1] != '1'):
		print('NO')
	else:
		print('YES')
		one = 0
		zer = 0
		for j in range(n):
			if s[j] == '1':
				one += 1
				if one <= c1 // 2:
					a += '('
					b += '('
				else:
					a += ')'
					b += ')'
			else:
				zer += 1
				if zer % 2 != 0:
					a += '('
					b += ')'
				else:
					a += ')'
					b += '('
		print(a)
		print(b)


import sys
input = sys.stdin.readline
YES = 'YES'
NO = 'NO'

def solve(N, S):
	if S[0] == 0 or S[-1] == 0:
		print(NO)
		return
	A = ['(']
	B = ['(']
	current_a = 1
	current_b = 1
	for s in S[1:-1]:
		if s:
			if current_a + current_b == 2:
				current_a += 1
				current_b += 1
				A.append('(')
				B.append('(')
			else:
				assert current_a > 0
				assert current_b > 0
				current_a -= 1
				current_b -= 1
				A.append(')')
				B.append(')')
		elif current_b - current_a == 2:
			assert current_b > 0
			current_a += 1
			current_b -= 1
			A.append('(')
			B.append(')')
		else:
			assert current_a > 0
			current_a -= 1
			current_b += 1
			A.append(')')
			B.append('(')
	if current_a != 1 or current_b != 1:
		print(NO)
		return
	A.append(')')
	B.append(')')
	print(YES)
	print(''.join(A))
	print(''.join(B))

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		S = list(map(int, input()[:-1]))
		solve(N, S)
main()


import sys
input = sys.stdin.readline

def check(K):
	z = 0
	for k in K:
		if k == '(':
			z += 1
		else:
			z -= 1
		if z < 0:
			return 0
	return 1
t = int(input())
for tests in range(t):
	n = int(input())
	s = input().strip()
	ONE = s.count('1')
	if ONE % 2 != 0:
		print('NO')
		continue
	A = [0] * n
	B = [0] * n
	z = 0
	o = 0
	for i in range(n):
		if s[i] == '1':
			o += 1
			if o <= ONE // 2:
				A[i] = '('
				B[i] = '('
			else:
				A[i] = ')'
				B[i] = ')'
		else:
			if z % 2 == 0:
				A[i] = '('
				B[i] = ')'
			else:
				A[i] = ')'
				B[i] = '('
			z += 1
	if check(A) == 1 and check(B) == 1:
		print('YES')
		print(''.join(A))
		print(''.join(B))
	else:
		print('NO')


def readInt():
	return int(input())

def readInts():
	return [int(x) for x in input().split()]

def readString():
	return input().rstrip()

def readCase():
	n = readInt()
	a = readString()
	return (n, a)

def solve(n, a):
	ones = a.count('1')
	if ones % 2 == 1:
		return 'NO'
	(first, second) = ('', '')
	(first_open, second_open) = (0, 0)
	ones_open_limit = ones // 2
	ones_used = 0
	for bit in a:
		if bit == '1':
			if ones_used < ones_open_limit:
				first += '('
				second += '('
				first_open += 1
				second_open += 1
			else:
				first += ')'
				second += ')'
				first_open -= 1
				second_open -= 1
			ones_used += 1
		elif first_open <= second_open:
			first += '('
			first_open += 1
			second += ')'
			second_open -= 1
		else:
			first += ')'
			first_open -= 1
			second += '('
			second_open += 1
		if first_open < 0 or second_open < 0:
			return 'NO'
	return '\n'.join(['YES', first, second])
cases = readInt()
for case in range(cases):
	print(solve(*readCase()))


from sys import stdin, stdout
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(stdin.readline())
	s1 = [0] * n
	s2 = [0] * n
	c = 0
	for i in range(n):
		if s[i] == '0':
			if c % 2:
				s1[i] = ')'
				s2[i] = '('
			else:
				s1[i] = '('
				s2[i] = ')'
			c += 1
	psum1 = [0] * n
	psum2 = [0] * n
	c1 = 0
	c2 = 0
	for i in range(n - 1, -1, -1):
		if s1[i] == ')':
			if c1 == 1:
				c1 = -1
			else:
				c1 -= 1
		elif s1[i] == '(':
			c1 += 1
		if s2[i] == ')':
			if c2 == 1:
				c2 = -1
			else:
				c2 -= 1
		elif s2[i] == '(':
			c2 += 1
		psum1[i] = c1
		psum2[i] = c2
	c1 = 0
	c2 = 0
	for i in range(n):
		if s1[i] == 0:
			if c1 <= max(-1 * psum1[i], 0) or c2 <= max(-1 * psum2[i], 0):
				s1[i] = '('
				s2[i] = '('
				c1 += 1
				c2 += 1
			else:
				s1[i] = ')'
				s2[i] = ')'
				c1 -= 1
				c2 -= 1
		elif s1[i] == '(':
			c1 += 1
			c2 -= 1
		else:
			c1 -= 1
			c2 += 1
	flag = True
	c1 = 0
	c2 = 0
	for i in range(n):
		if s1[i] == '(':
			c1 += 1
		else:
			c1 -= 1
		if s2[i] == '(':
			c2 += 1
		else:
			c2 -= 1
		if c1 < 0 or c2 < 0:
			flag = False
			break
	if flag and c1 == 0 and (c2 == 0):
		stdout.write('YES\n')
		for i in s1:
			stdout.write(i)
		stdout.write('\n')
		for i in s2:
			stdout.write(i)
	else:
		stdout.write('NO')
	stdout.write('\n')


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	s = input().strip()
	c = s.count('1')
	if c % 2 == 1 or n % 2 == 1:
		print('NO')
		return
	c //= 2
	b = 0
	b1 = 0
	b2 = 0
	s1 = []
	s2 = []
	for i in s:
		if i == '1':
			if c > 0:
				s1.append('(')
				s2.append('(')
				c -= 1
				b1 += 1
				b2 += 1
			else:
				s1.append(')')
				s2.append(')')
				b1 -= 1
				b2 -= 1
		else:
			if b:
				s1.append(')')
				s2.append('(')
				b1 -= 1
				b2 += 1
			else:
				s1.append('(')
				s2.append(')')
				b1 += 1
				b2 -= 1
			b ^= 1
		if b1 < 0 or b2 < 0:
			print('NO')
			return
	if b1 == 0 and b2 == 0:
		print('YES')
		print(''.join(s1))
		print(''.join(s2))
	else:
		print('NO')
for i in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	k = s.count('1')
	m = s.count('0')
	if s[0] == '0' or s[n - 1] == '0' or m % 2 != 0 or (k % 2 != 0):
		print('NO')
		continue
	a = ''
	b = ''
	d = 0
	c = 0
	for i in s:
		if i == '1':
			if d < k / 2:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
			d += 1
		else:
			if c % 2 == 0:
				a += ')'
				b += '('
			else:
				a += '('
				b += ')'
			c += 1
	print('YES')
	print(a)
	print(b)


Time = int(input())

def solve():
	N = int(input())
	S = input()
	cnt = S.count('1')
	if S[0] == '0' or S[-1] == '0' or cnt % 2 == 1:
		print('NO')
		return
	(A, B) = ('', '')
	k = 0
	flip = False
	for i in range(N):
		if S[i] == '1':
			if 2 * k < cnt:
				A += '('
				B += '('
			else:
				A += ')'
				B += ')'
			k += 1
		else:
			if flip:
				A += '('
				B += ')'
			else:
				A += ')'
				B += '('
			flip = not flip
	print('YES')
	print(A)
	print(B)
for _ in range(Time):
	solve()


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	data = sys.stdin.readline().rstrip()
	cnt_one = 0
	for i in data:
		if i == '1':
			cnt_one += 1
	if data[0] == '0' or data[-1] == '0' or cnt_one % 2 == 1:
		print('NO')
		continue
	(fir_ans, sec_ans) = ('', '')
	(idx, record) = (0, 1)
	for i in range(n):
		if data[i] == '1':
			fir_ans += ')' if 2 * idx >= cnt_one else '('
			sec_ans += fir_ans[-1]
			idx += 1
		else:
			fir_ans += ')' if record == 1 else '('
			sec_ans += '(' if record == 1 else ')'
			record = -record
	print('YES')
	print(fir_ans)
	print(sec_ans)


import sys
import math
import bisect
import functools
from functools import lru_cache
from sys import stdin, stdout
from math import gcd, floor, sqrt, log, ceil
from heapq import heappush, heappop, heapify
from collections import defaultdict as dd
from collections import Counter as cc
from bisect import bisect_left as bl
from bisect import bisect_right as br

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
sys.setrecursionlimit(100000000)
intinp = lambda : int(input().strip())
stripinp = lambda : input().strip()
fltarr = lambda : list(map(float, input().strip().split()))
intarr = lambda : list(map(int, input().strip().split()))
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
MOD = 1000000007
num_cases = intinp()
for _ in range(num_cases):
	n = intinp()
	s = stripinp()
	(a, b) = ('', '')
	o = s.count('1')
	z = s.count('0')
	(one, zero) = (0, 0)
	if s[0] != '1' or s[-1] != '1' or o % 2 or z % 2:
		print('NO')
		continue
	for (i, v) in enumerate(s):
		if v == '1':
			one += 1
			if one > o // 2:
				a += ')'
				b += ')'
			else:
				a += '('
				b += '('
		else:
			zero += 1
			if zero % 2 == 0:
				a += ')'
				b += '('
			else:
				a += '('
				b += ')'
	print('YES')
	print(a)
	print(b)


def solve():
	n = int(input())
	s = input()
	count = c = 0
	for j in range(n):
		if s[j] == '0':
			count += 1
		else:
			c += 1
	if s[0] == '0' or s[n - 1] == '0' or count % 2:
		print('NO')
		return
	a = ''
	b = ''
	f = 0
	c = int(c / 2)
	one = 0
	for j in range(n):
		if s[j] == '0':
			if f:
				a += ')'
				b += '('
			else:
				a += '('
				b += ')'
			f ^= 1
		else:
			if c > one:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
			one += 1
	print('YES')
	print(a)
	print(b)
t = int(input())
for i in range(t):
	solve()


for t in range(int(input())):
	n = int(input())
	s = input()
	ans = 'YES'
	cnt = s.count('1')
	if s[0] == '0' or s[-1] == '0' or cnt % 2 == 1:
		ans = 'NO'
	else:
		(a, b) = ('', '')
		check = 0
		temp = False
		for i in range(n):
			if s[i] == '0':
				if temp:
					a += ')'
					b += '('
				else:
					a += '('
					b += ')'
				temp = not temp
			else:
				if check * 2 < cnt:
					a += '('
					b += '('
				else:
					a += ')'
					b += ')'
				check += 1
	print(ans)
	if ans == 'YES':
		print(a)
		print(b)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input()))
	o = l.count(1)
	z = l.count(0)
	if n % 2 != 0:
		print('NO')
	elif o % 2 != 0:
		print('NO')
	elif l[0] == 0 or l[n - 1] == 0:
		print('NO')
	else:
		print('YES')
		a = ''
		b = ''
		for i in range(n):
			if l[i] == 1:
				if o != 0:
					a += '('
					b += '('
					o -= 2
				else:
					a += ')'
					b += ')'
			elif z % 2 == 0:
				a += ')'
				b += '('
				z -= 1
			else:
				a += '('
				b += ')'
				z -= 1
		print(a)
		print(b)


def solve():
	n = int(input())
	s = input()
	c = []
	b = []
	z = s.count('1')
	if s[0] != '1' or s[-1] != '1':
		print('NO')
	else:
		p = n - z
		if p % 2:
			print('NO')
			return
		k = 0
		t = 0
		for j in s:
			if j == '1':
				if k < z // 2:
					c.append('(')
					b.append('(')
					k = k + 1
				else:
					c.append(')')
					b.append(')')
			elif t == 0:
				c.append('(')
				b.append(')')
				t = 1
			else:
				c.append(')')
				b.append('(')
				t = 0
		print('YES')
		print(''.join(c))
		print(''.join(b))
for _ in range(int(input())):
	solve()


import sys, collections
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	N = int(input())
	S = sys.stdin.readline().strip()
	total1 = total2 = 0
	C1 = C2 = 0
	if S[0] == '0' or S[-1] == '0':
		print('NO')
		continue
	if S.count('0') & 1:
		print('NO')
		continue
	st1 = ''
	st2 = ''
	cnt0 = 0
	cnt1 = 0
	ONE = S.count('1')
	for i in S:
		if i == '1':
			cnt1 += 1
			if cnt1 <= ONE // 2:
				st1 += '('
				st2 += '('
			else:
				st1 += ')'
				st2 += ')'
		else:
			cnt0 += 1
			if cnt0 & 1:
				st1 += '('
				st2 += ')'
			else:
				st1 += ')'
				st2 += '('
	print('YES')
	print(st1)
	print(st2)


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	a = ''
	b = ''
	one = 0
	zero = 0
	for i in s:
		if i is '1':
			one += 1
		elif i is '0':
			zero += 1
	if zero % 2 == 1 or one % 2 == 1 or s[0] == '0' or (s[-1] == '0'):
		print('NO')
	else:
		for i in s:
			if i == '1':
				if one:
					a += '('
					b += '('
					one -= 2
				else:
					a += ')'
					b += ')'
			elif zero % 2 == 0:
				a += ')'
				b += '('
				zero -= 1
			else:
				a += '('
				b += ')'
				zero -= 1
		print('YES')
		print(a)
		print(b)
	t -= 1


def solve():
	n = int(input())
	s = input()
	if s[len(s) - 1] == '0' or s[0] == '0':
		print('NO')
		return
	else:
		ones = 0
		for i in range(len(s)):
			ones += s[i] == '1'
		if ones % 2 == 1:
			print('NO')
			return
		else:
			print('YES')
			sol1 = [None] * n
			sol2 = [None] * n
			cojones = ones
			ones = 0
			for i in range(n):
				if s[i] == '1':
					if ones < cojones / 2:
						sol1[i] = '('
						sol2[i] = '('
					else:
						sol1[i] = ')'
						sol2[i] = ')'
					ones += 1
			alt = 0
			for i in range(n):
				if s[i] == '0':
					if alt == 0:
						alt = 1
						sol1[i] = '('
						sol2[i] = ')'
					else:
						alt = 0
						sol1[i] = ')'
						sol2[i] = '('
			for i in range(n):
				print(sol1[i], end='')
			print()
			for i in range(n):
				print(sol2[i], end='')
			print()
	return 0
t = int(input())
while t:
	solve()
	t -= 1


t = int(input())
while t:
	n = int(input())
	s = input()
	o = s.count('1')
	if s[0] == '0' or s[-1] == '0' or s.count('0') % 2 != 0 or (o % 2 != 0):
		print('NO')
	else:
		a = ''
		b = ''
		open_flag = 1
		p = o // 2
		for x in s:
			if x == '1':
				if p > 0:
					a += '('
					b += '('
					p -= 1
				else:
					a += ')'
					b += ')'
			else:
				if open_flag:
					a += ')'
					b += '('
				else:
					a += '('
					b += ')'
				open_flag = 0 if open_flag else 1
		print('YES')
		print(a)
		print(b)
	t -= 1


for j in range(int(input())):
	n = int(input())
	s = input()
	if s.count('0') % 2 != 0 or s[0] == '0' or s[-1] == '0':
		print('NO')
	else:
		print('YES')
		k = s.count('1')
		r = ''
		f = ''
		t = 0
		p = 0
		i = 0
		while i < n:
			if s[i] == '1':
				if t * 2 < k:
					r += '('
					f += '('
				else:
					r += ')'
					f += ')'
				t += 1
			else:
				if p == 0:
					r += '('
					f += ')'
				else:
					r += ')'
					f += '('
				p = (p + 1) % 2
			i += 1
		print(r)
		print(f)


def count(string, character):
	count = 0
	for i in range(len(string)):
		if string[i] == character:
			count = count + 1
	return count
for t in range(int(input())):
	n = int(input())
	s = input()
	zc = count(s, '0')
	if zc % 2 == 1 or s[0] == '0' or s[-1] == '0':
		print('NO')
	else:
		oc = count(s, '1')
		a = ''
		b = ''
		c = 0
		flag = 1
		for i in range(len(s)):
			if s[i] == '1':
				c = c + 1
				if c <= oc // 2:
					a = a + '('
					b = b + '('
				else:
					a = a + ')'
					b = b + ')'
			else:
				if flag == 1:
					a = a + '('
					b = b + ')'
				else:
					a = a + ')'
					b = b + '('
				flag = not flag
		print('YES')
		print(a)
		print(b)


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

def li():
	return [int(i) for i in input().split()]
for t in range(ii()):
	n = ii()
	s = input()
	ones = 0
	if s[0] != '1' or s[n - 1] != '1':
		print('NO')
	else:
		for i in range(n):
			ones += s[i] == '1'
		if ones % 2 == 1:
			print('NO')
		else:
			a = ''
			b = ''
			ones //= 2
			flag = 0
			for i in range(n):
				if s[i] == '1':
					if ones > 0:
						a += '('
						b += '('
						ones -= 1
					else:
						a += ')'
						b += ')'
				elif flag == 0:
					flag = 1
					a += '('
					b += ')'
				else:
					flag = 0
					a += ')'
					b += '('
			print('YES')
			print(a)
			print(b)


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s[0] == s[-1] == '0' or s[0] != s[-1]:
		print('NO')
		continue
	if s.count('0') % 2:
		print('NO')
		continue
	cnt = s.count('1')
	k = 0
	a = ''
	b = ''
	flip = True
	for i in s:
		if i == '1':
			if 2 * k < cnt:
				a += '('
			else:
				a += ')'
			b += a[-1]
			k += 1
		else:
			if flip:
				a += '('
				b += ')'
			else:
				a += ')'
				b += '('
			flip = not flip
	print('YES')
	print(a)
	print(b)


t = int(input())

def valid(s):
	tmp = 0
	for c in s:
		if c == '(':
			tmp += 1
		else:
			tmp -= 1
		if tmp < 0:
			return False
	return True
for _ in range(t):
	n = int(input())
	s = input()
	(a, b) = ('', '')
	c1 = s.count('1')
	if c1 % 2 or n % 2:
		print('NO')
		continue
	c1 //= 2
	t1 = 0
	t = 0
	for c in s:
		if c == '1':
			if t1 < c1:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
			t1 += 1
		else:
			if t == 0:
				a += '('
				b += ')'
			else:
				a += ')'
				b += '('
			t ^= 1
	if valid(a) and valid(b):
		print('YES')
		print(a)
		print(b)
	else:
		print('NO')


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, S):
	A = [0] * N
	B = [0] * N
	numSame = S.count('1')
	numDiff = N - numSame
	if numSame % 2 != 0 or numDiff % 2 != 0:
		return 'NO'
	usedSame = 0
	usedDiff = 0
	for i in range(N):
		if S[i] == '1':
			if usedSame < numSame // 2:
				A[i] = '('
				B[i] = '('
				usedSame += 1
			else:
				A[i] = ')'
				B[i] = ')'
		else:
			if usedDiff % 2 == 0:
				A[i] = '('
				B[i] = ')'
			else:
				A[i] = ')'
				B[i] = '('
			usedDiff += 1
	bal1 = 0
	bal2 = 0
	for (a, b) in zip(A, B):
		if a == '(':
			bal1 += 1
		else:
			bal1 -= 1
		if b == '(':
			bal2 += 1
		else:
			bal2 -= 1
		if bal1 < 0 or bal2 < 0:
			return 'NO'
	if bal1 != 0 or bal2 != 0:
		return 'NO'
	return 'YES\n' + ''.join(A) + '\n' + ''.join(B)
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	S = input().decode().rstrip()
	ans = solve(N, S)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	string = input()
	if string[0] != '1' or string[-1] != '1':
		print('NO')
		continue
	else:
		ones = string.count('1')
		zeros = n - ones
		if ones % 2 == 1:
			print('NO')
			continue
		output1 = [-1] * n
		output2 = [-1] * n
		countOne = 0
		g = 0
		for i in range(n):
			if string[i] == '1':
				if countOne < ones / 2:
					output1[i] = '('
					output2[i] = '('
				else:
					output1[i] = ')'
					output2[i] = ')'
				countOne += 1
			else:
				if g == 0:
					output1[i] = '('
					output2[i] = ')'
				else:
					output1[i] = ')'
					output2[i] = '('
				g ^= 1
		print('YES')
		print(''.join(output1))
		print(''.join(output2))


for i in range(int(input())):
	n = int(input())
	s = input()
	cnt = 0
	for i in s:
		if i == '0':
			cnt += 1
	if cnt % 2 == 1 or s[0] == '0' or s[n - 1] == '0':
		print('NO')
		continue
	a = ''
	b = ''
	turn = False
	cnt1 = n - cnt
	c1 = 0
	for i in s:
		if i == '0':
			if turn:
				a += '('
				b += ')'
			else:
				a += ')'
				b += '('
			turn ^= 1
		else:
			c1 += 1
			if c1 <= cnt1 // 2:
				a += '('
				b += '('
			else:
				a += ')'
				b += ')'
	print('YES\n', a, '\n', b)


def some_random_function():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function5():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)
import os, sys
from io import BytesIO, IOBase

def check(a):
	x = 0
	for i in a:
		if i == '(':
			x += 1
		else:
			x -= 1
		if x < 0:
			return 0
	return 1

def solve(n, s):
	x = s.count('0')
	if x & 1:
		print('NO')
		return
	(a, b) = ([0] * n, [0] * n)
	(z, cou) = (0, (n - x) // 2)
	for i in range(n):
		if s[i] == '1':
			if cou:
				(a[i], b[i]) = ('(', '(')
				cou -= 1
			else:
				(a[i], b[i]) = (')', ')')
		else:
			if z:
				(a[i], b[i]) = (')', '(')
			else:
				(a[i], b[i]) = ('(', ')')
			z ^= 1
	if check(a) and check(b):
		print('YES')
		print(''.join(a))
		print(''.join(b))
	else:
		print('NO')

def main():
	for _ in range(int(input())):
		n = int(input())
		s = input().strip()
		solve(n, s)
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 some_random_function1():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function2():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function3():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function4():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function6():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function7():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function8():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)
main()


testcases = int(input())
while testcases > 0:
	n = int(input())
	str1 = str(input())
	count1 = 0
	for a in range(0, n):
		if str1[a] == '1':
			count1 += 1
	if count1 % 2 == 1 or str1[0] == '0' or str1[n - 1] == '0':
		print('NO')
		testcases = testcases - 1
		continue
	flip = True
	a = ''
	b = ''
	k = 0
	for i in range(0, n):
		if str1[i] == '1':
			temp = '(' if k * 2 < count1 else ')'
			a = a + temp
			b = b + temp
			k += 1
		else:
			temp = ')' if flip else '('
			a = a + temp
			temp2 = '(' if flip else ')'
			b = b + temp2
			flip = not flip
	print('YES')
	print(a.strip())
	print(b.strip())
	testcases = testcases - 1


import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.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 = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.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:
			self.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 get_int():
	return int(input())

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

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

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

def get_strs():
	return get_str().split(' ')

def flat_list(arr):
	return [item for subarr in arr for item in subarr]

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def binary_search(good, left, right, delta=1, right_true=False):
	limits = [left, right]
	while limits[1] - limits[0] > delta:
		if delta == 1:
			mid = sum(limits) // 2
		else:
			mid = sum(limits) / 2
		if good(mid):
			limits[int(right_true)] = mid
		else:
			limits[int(~right_true)] = mid
	if good(limits[int(right_true)]):
		return limits[int(right_true)]
	else:
		return False

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def is_pall(s):
	n = len(s)
	for i in range(n // 2):
		if s[i] != s[n - 1 - i]:
			return False
	return True

def solve_a():
	s = get_str()
	n = len(s)
	s_set = set(s)
	if s_set == {'a'}:
		return print('NO')
	else:
		print('YES')
		if is_pall(s + 'a'):
			print('a' + s)
		else:
			print(s + 'a')

def solve_b():
	n = get_int()
	a = list(get_str())
	b = list(get_str())
	if a.count('1') != b.count('1'):
		return False
	a_cnt = [0, 0]
	prev = 0
	for i in range(n):
		a_cnt[int(a[i])] += 1
		if a_cnt[0] == a_cnt[-1]:
			same = False
			diff = False
			for j in range(prev + 1, i + 1):
				if a[j] != b[j]:
					diff = True
				else:
					same = True
			if same and diff:
				return False
			prev = i
	for j in range(prev + 1, n):
		if a[j] != b[j]:
			return False
	return True

def brack_seq_good(seq):
	opens = 0
	for (i, char) in enumerate(seq):
		if char == '(':
			opens += 1
		else:
			opens -= 1
		if opens < 0:
			return False
	return opens == 0

def solve_c():
	n = get_int()
	s = get_str()
	x = s.count('1')
	if x % 2 == 1:
		print('NO')
		return
	(open_u, open_v) = (0, 0)
	u = []
	v = []
	ones = 0
	for (i, char) in enumerate(s):
		if char == '1':
			if ones < x // 2:
				u.append('(')
				v.append('(')
				open_u += 1
				open_v += 1
			else:
				u.append(')')
				v.append(')')
				open_u -= 1
				open_v -= 1
			ones += 1
		elif open_u < open_v:
			u.append('(')
			v.append(')')
			open_u += 1
			open_v -= 1
		else:
			u.append(')')
			v.append('(')
			open_u -= 1
			open_v += 1
		if min(open_u, open_v) < 0:
			print('NO')
			return
	if max(open_u, open_v):
		print('NO')
		return
	print('YES')
	print(''.join(u))
	print(''.join(v))
	return
	if s[0] != '1':
		print('NO')
		return
	elif s[-1] != '1':
		print('NO')
		return
	elif s.count('1') % 2 != 0:
		print('NO')
		return
	else:
		candidates = []
		candidates.append(['(', ')'] * (n // 2))
		candidates.append(['('] * (n // 2) + [')'] * (n // 2))
		for x in candidates:
			y = []
			for (i, char) in enumerate(x):
				if s[i] == '1':
					y.append(char)
				elif char == '(':
					y.append(')')
				else:
					y.append('(')
			if brack_seq_good(y):
				print('YES')
				print(''.join(x))
				print(''.join(y))
				return

def solve_d():
	n = get_int()
	grid = [(i + 1, j + 1) for i in range(n) for j in range(n)]
	odds = [(i, j) for (i, j) in grid if (i + j) % 2]
	evens = [(i, j) for (i, j) in grid if (i + j) % 2 == 0]

	def turn():
		a = get_int()
		if a == 1:
			if evens:
				(i, j) = evens.pop()
				print(2, i, j)
				sys.stdout.flush()
				return
			elif odds:
				(i, j) = odds.pop()
				print(3, i, j)
				sys.stdout.flush()
				return
		elif a == 2:
			if odds:
				(i, j) = odds.pop()
				print(1, i, j)
				sys.stdout.flush()
				return
			elif evens:
				(i, j) = evens.pop()
				print(3, i, j)
				sys.stdout.flush()
				return
		elif a == 3:
			if odds:
				(i, j) = odds.pop()
				print(1, i, j)
				sys.stdout.flush()
				return
			elif evens:
				(i, j) = evens.pop()
				print(2, i, j)
				sys.stdout.flush()
				return
	for i in range(n ** 2):
		turn()
	return
t = get_int()
for _ in range(t):
	solve_c()


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	N = int(input())
	X = [int(a) for a in input()]
	s = sum(X)
	if s % 2 or X[0] == 0 or X[-1] == 0:
		print('NO')
		continue
	A = [0] * N
	B = [0] * N
	k = 0
	l = 1
	for (i, x) in enumerate(X):
		if x:
			k += 1
			if k * 2 <= s:
				A[i] = B[i] = 1
		else:
			A[i] = l
			l ^= 1
			B[i] = l
	print('YES')
	print(''.join(['(' if a else ')' for a in A]))
	print(''.join(['(' if a else ')' for a in B]))


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	a = [0] * n
	b = [0] * n
	ao = bo = 0
	poss = True
	s = input()
	for i in range(n):
		if s[i] == '1':
			if ao == 0 or bo == 0 or (ao == bo == 1 and i < n - 1):
				ao += 1
				bo += 1
				a[i] = '('
				b[i] = '('
			else:
				ao -= 1
				bo -= 1
				a[i] = ')'
				b[i] = ')'
		elif ao > bo:
			ao -= 1
			bo += 1
			a[i] = ')'
			b[i] = '('
		elif bo > 0:
			bo -= 1
			ao += 1
			a[i] = '('
			b[i] = ')'
		else:
			poss = False
	if ao == bo == 0 and poss:
		print('YES')
		print(*a, sep='')
		print(*b, sep='')
	else:
		print('NO')


import sys, functools, collections, bisect, math, heapq
input = sys.stdin.readline
sys.setrecursionlimit(200000)
mod = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	n = int(input())
	s = input().strip()
	if s[0] == '0' or s[-1] == '0':
		print('NO')
		continue
	d = collections.Counter(s)
	if d['0'] % 2 or d['1'] % 2:
		print('NO')
		continue
	res1 = [1] * n
	res2 = [1] * n
	x = d['1'] // 2
	i = 0
	while x:
		if s[i] == '1':
			res1[i] = '('
			res2[i] = '('
			x -= 1
		i += 1
		if x == 0:
			while i < n:
				if s[i] == '1':
					res1[i] = ')'
					res2[i] = ')'
				i += 1
	c = 0
	for i in range(n):
		if s[i] == '0':
			if c % 2:
				res1[i] = ')'
				res2[i] = '('
			else:
				res1[i] = '('
				res2[i] = ')'
			c += 1
	print('YES')
	print(''.join(res1))
	print(''.join(res2))


for _ in range(int(input())):
	n = int(input())
	s = input()
	ones = s.count('1')
	if s[0] == '0' or s[n - 1] == '0' or ones % 2 == 1:
		print('NO')
	else:
		var = 0
		flag = 1
		a = ''
		b = ''
		for i in range(n):
			if s[i] == '1':
				if 2 * var < ones:
					a += '('
					b += '('
				else:
					a += ')'
					b += ')'
				var += 1
			else:
				if flag == 1:
					a += ')'
					b += '('
				else:
					a += '('
					b += ')'
				flag = 1 - flag
		print('YES')
		print(a)
		print(b)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	s = input()
	o = s.count('1')
	z = n - o
	c = 0
	o = o // 2
	opn = False
	done = False
	if z % 2:
		print('NO')
	else:
		(a, b) = ('', '')
		for i in s:
			if i == '1':
				if o:
					c += 1
					a += '('
					b += '('
					o -= 1
				else:
					a += ')'
					b += ')'
					c -= 1
			elif c:
				if opn:
					a += '('
					b += ')'
				else:
					b += '('
					a += ')'
				opn = not opn
			else:
				print('NO')
				done = True
				break
		if not done:
			print('YES')
			print(a)
			print(b)