#include<bits/stdc++.h>
#define ll long long
#define cmax(a,b) a=max(a,b)
#define pii pair<int,int>
#define fi first
#define se second
#define pii pair<int,int>
#define mkp make_pair
#define pk push_back
using namespace std;
const int maxn=4e5+10;
int ans[maxn];
string s;
int main() {
	int T;
	cin>>T;
	while (T--) {
		int n;
		cin>>n;
		cin>>s;
		s=" "+s;
		int a=0,b=0;
		for (int l=1;l<=n;l++) {
			if (s[l]=='0') a++;
			if (s[l]=='1') b++;
		}
		if (s[1]!='1'||s[n]!='1'||a%2==1) {
			cout<<"NO"<<endl;
			continue;
		}
		a=0,b=0;
		bool bx=1;
		for (int l=1;l<=n;l++) {
			if (s[l]=='0') {
				if (a==0&&b==0) {
					bx=0;
					break;
				}
				if (a>b) {
					ans[l]=1;
					a--;b++;
				} else {
					ans[l]=0;
					a++;b--;
				}
			}
			if (s[l]=='1') {
				if (a==1&&b==1&&s[l+1]=='0') {
					ans[l]=1;
					a++,b++;
				} else if (a==0||b==0) {
					ans[l]=1;
					a++,b++;
				} else {
					ans[l]=0;
					a--;b--;
				}
			}
		}
		if (bx==0||a!=0||b!=0) {
			cout<<"NO"<<endl;
			continue;
		}
		cout<<"YES"<<endl;
		for (int l=1;l<=n;l++) {
			if (ans[l]==1) cout<<'(';
			else cout<<')';
		}
		cout<<endl;
		for (int l=1;l<=n;l++) {
			if (ans[l]==1&&s[l]=='1') cout<<'(';
			if (ans[l]==1&&s[l]=='0') cout<<')';
			if (ans[l]==0&&s[l]=='1') cout<<')';
			if (ans[l]==0&&s[l]=='0') cout<<'(';
		}
		cout<<endl;
	}
} 