#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#ifdef dremix
    #define p(x) cerr<<#x<<" = "<<x<<endl;
    #define p2(x,y) cerr<<#x<<" , "<<#y<<" = "<<x<<" , "<<y<<endl;
    #define pp(x) cerr<<#x<<" = ("<<x.F<<" , "<<x.S<<")"<<endl;
    #define pv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u<<", ";cerr<<"}"<<endl;
    #define ppv(x) cerr<<#x<<" = {";for(auto u : x)cerr<<u.F<<"-"<<u.S<<", ";cerr<<"}"<<endl;
#else
    #define p(x)
    #define p2(x,y)
    #define pp(x)
    #define pv(x)
    #define ppv(x)
#endif
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
const int maxp = 22;
const ld EPS = 1e-18;
const ll INF = 2e18;
const int MOD = 1e9+7;
const int N = 2e5+1;
void yesno(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
ll power(ll x, ll n, ll m){if(n==0)return 1;ll u=power(x,n/2,m);u=(u*u)%m;if(n%2)u=(u*x)%m;return u;}
/// * int overflow, array bounds
/// * special cases (n=1?)
/// * do something - write observations down
/// * change approaches

void pro(string &a, string &b, int cnt[], int add){
    a += '(';
    b += ')';
    cnt[add] ++;
    cnt[add^1] --;
}

int main (){
fastio;

int t;
cin>>t;

while(t--){
    int n;
    cin>>n;
    string s;
    cin>>s;

    int i;
    string a,b;
    a = b = "";

    bool ok = 1;

    int cnt[2] = {},curr[2] = {};

    for(i=0;i<n;i++){
        cnt[s[i]-'0']++;
    }

    if(cnt[0] % 2){
        cout<<"NO"<<endl;
        continue;
    }

    int open = 0;
    bool f = true, ans = true;

    for(i=0;i<n;i++){
        if(s[i] == '0'){
            if(f)
                pro(a,b,curr,0);
            else
                pro(b,a,curr,1);
            f ^= 1;
        }
        else{
            if(open == cnt[1]/2){
                a += ')';
                b += ')';
                curr[0] --;
                curr[1] --;
            }
            else{
                a += '(';
                b += '(';
                curr[0] ++;
                curr[1] ++;
                open++;
            }
        }
        if(curr[0] < 0 || curr[1] < 0){
            ans = false;
            break;
        }
    }
    if(curr[0] || curr[1])
        ans = false;

    if(!ans)
        cout<<"NO";
    else{
        cout<<"YES"<<endl<<a<<endl<<b;
    }
    cout<<endl;

}


}
