#include<bits/stdc++.h>
#define int      long long int
#define nitro    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb       push_back
#define pi       3.1415926535897932384626
#define mod      1000000007
#define endl     '\n'
#define DEBUG    false
#define F        first
#define S        second
#pragma GCC optimize "trapv"

using namespace std;


int32_t main()
{
 nitro;
 /*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
 #endif*/
 int t;
 cin>>t;
 while(t--)
 {
     int n;
     cin>>n;
     string s;
     cin>>s;
     int c=1;
     std::vector<int> v(n,0);
     std::stack<pair<char,int>> st1,st2;
     st1.push({s[0],c});
     v[0]=c;
     for(int i=1;i<n;i++)
     {
         if(s[i]=='0')
         {
             if(st1.top().F=='1')
             {
                 int k=st1.top().S;
                 st1.push({s[i],k});
                 v[i]=k;
             }
             else if(st2.size()==0)
             {
                 c++;
                 st2.push({s[i],c});
                 v[i]=c;
             }
             else if(st2.top().F=='1')
             {
                 int k=st2.top().S;
                 st2.push({s[i],k});
                 v[i]=k;
             }
             else
             {
                 c++;
                 v[i]=c;
             }
         }
         else
         {
             if(st1.top().F=='0')
             {
                 int k=st1.top().S;
                 st1.push({s[i],k});
                 v[i]=k;
             }
             else if(st2.size()==0)
             {
                 c++;
                 st2.push({s[i],c});
                 v[i]=c;
             }
             else if(st2.top().F=='0')
             {
                 int k=st2.top().S;
                 st2.push({s[i],k});
                 v[i]=k;
             }
             else
             {
                 c++;
                 v[i]=c;
             }
         }
     }
     cout<<c<<endl;
     for(auto i:v)
     cout<<i<<" ";
     cout<<endl;
 }
 return 0;
}