#include<bits/stdc++.h>#define INF 0x3f3f3f3ftypedeflonglong ll ;usingnamespace std;constint maxN =200005;intread(){int x =0, f =1;char ch =getchar();while(ch <'0'|| ch >'9'){if(ch =='-') f =-f; ch =getchar();}while(ch >='0'&& ch <='9'){ x = x *10+ ch -'0'; ch =getchar();}return x * f;}int ans[maxN];int lst_zero[maxN];//上一个以0结尾的编号int lst_one[maxN];//上一个以1结尾的编号voidinit(int n){for(int i =0; i <= n;++ i ){
lst_zero[i]= lst_one[i]= ans[i]=0;}}intmain(){int t; t =read();while(t --){int n; n =read();init(n);
string s; cin >> s;int top =0;//目前编号的上限int one =0, zero =0;//以0结尾的编号,以1结尾的编号for(int i =0; i < n;++ i ){if(s[i]=='0'){if(one){//以1结尾的,要跟0了
ans[i]= one;
lst_zero[one]= zero;
zero = one;}else{
ans[i]=++ top;
lst_zero[top]= zero;
zero = top;}
one = lst_one[one];}else{if(zero){
ans[i]= zero;
lst_one[zero]= one;
one = zero;}else{
ans[i]=++ top;
lst_one[top]= one;
one = top;}
zero = lst_zero[zero];}}
cout << top << endl;for(int i =0; i < n;++ i ){
cout << ans[i]<<' ';}
cout << endl;}return0;}