#include <bits/stdc++.h>
using namespace std;
#define int              long long int
#define double           long double
#define print(a)         for(auto x : a) cout << x << " "; cout << endl


const int M = 1000000007;
const int N = 3e5+9;
const int INF = 2e9+1;
const int LINF = 2000000000000000001;

inline int power(int a, int b) {
    int x = 1;
    a %= M;
    while (b) {
        if (b & 1) x = (x * a) % M; 
        a = (a * a) % M;
        b >>= 1;
    }
    return x;
}


//_ ***************************** START Below *******************************




string a;


pair<int, vector<int>> consistency(int n){

    vector<int> b(n);
    int br = 0;
    for(int i=0; i<n; i++){
        if(a[i] == '(') br++;
        else br--;
        b[i] = br;
    }

    if(br != 0){
        return {-1, {}};
    }

    vector<int> ans(n, 0);
    bool isColor1 = false;
    bool isColor2 = false;

    int i = 0;
    while(i<n){
        while(i<n && b[i] >= 0){
            ans[i] = 1;
            isColor1 = true;
            i++;
        }

        int j = i;
        while(j<n && b[j] <= 0){
            ans[j] = 2;
            isColor2 = true;
            j++;
        }
        i = j;
    }

    if(isColor1 && isColor2){
        return {2, ans};
    }

    ans.assign(n, 1);

    return {1, ans};    

}














pair<int, vector<int>> practice(int n){


}





void solve() {
    
    int n;
    cin>> n;

    cin >> a;
    
    auto ans = consistency(n);

    cout << ans.first << endl;
    if(ans.first != -1){
        for(auto& it : ans.second){
            cout << it << " ";
        }cout << endl;
    }


}





int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}