 // "It does not matter how slowly you go as long as you do not stop." - Confucius
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
#include<stack>
#include<queue>
#include<climits>
#include<tuple>
using namespace std;
#define pb push_back
#define ff(i,a,b) for(int i=a;i<b;++i)
#define ffr(i,b,a) for(int i=b;i>=a;--i)
#define fflr(i,b,a) for(long long i=b;i>=a;--i)
#define ffl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define endl '\n'
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define trav(a,x) for (auto& a : x)
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define collect(v, n)            \
    for (ll i = 0; i < n; i++) { \
        cin >> v[i];             \
    }
#define X first
#define Y second
#define mp make_pair
#define mt make_tuple
typedef long long ll;
typedef long double ld;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef std::vector<int> vec;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

void FAST() {	// FAST Input Output, DONT use both scnaf,printf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

const ll md = 1000000007;
#define pi 3.141592653589793238462643383279
const ll inf = 1e18L + 5;  // max 1000*inf
const char nl = '\n';
const int N=200005;



int main() {
	FAST();int tt{},T{};tt=1;  cin>>tt;T=tt;
 	while(tt--){
        //cout<<"--------Test:"<<T-tt<<endl;
        string str,sa,sb;
        int n{},m{},ans{},k{},a{},b{},c{},x{},y{},f{},q{};  
        
        
        cin>>n; //vec v(n); ff(i,0,n)cin>>v[i];
        cin>>str;
        vec w;
        ff(i,0,n){
            if(str[i]=='1'){
                sa+="(";sb+="(";++a;++b;
                w.pb(i);
            }else{
                if(a<0||b<0){
                    f=1;break;
                }else if(a*b==0){
                    if(a+b==0){
                        f=1;break;
                    }
                    if(a==0){
                        sa+="(";sb+=")";++a;--b;
                    }else{
                        sa+=")";sb+="(";--a;++b;
                    }
                }else{
                    if(a>=b){
                        sa+=")";sb+="(";--a;++b;
                    }else{
                        sa+="(";sb+=")";++a;--b;
                    }
                }
            }
        }
        if(f){
            No;
            continue;
        }
        if(a==b&&a>0&&a%2==0&&w.size()>0){
            reverse(all(w));
            trav(e,w){
                sa[e]=sb[e]=')';a-=2;b-=2;
                if(a<=0||b<=0)break;
            }
        }
        
        x=0;
        ff(i,0,n){
            if(sa[i]=='(')++x;
            else --x;
            if(x<0)f=1;
        }
        if(x!=0)f=1;
        x=0;
        ff(i,0,n){
            if(sb[i]=='(')++x;
            else --x;
            if(x<0)f=1;
        }
        if(x!=0)f=1;
        
        if(f||a!=0||b!=0){
            No;
        }else{
            Yes;
            cout<<sa<<nl<<sb<<nl;
        }
        
    }
    
	return 0;
}