#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;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBpbnQgICAgICBsb25nIGxvbmcgaW50CiNkZWZpbmUgbml0cm8gICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSksY2luLnRpZShOVUxMKSxjb3V0LnRpZShOVUxMKTsKI2RlZmluZSBwYiAgICAgICBwdXNoX2JhY2sKI2RlZmluZSBwaSAgICAgICAzLjE0MTU5MjY1MzU4OTc5MzIzODQ2MjYKI2RlZmluZSBtb2QgICAgICAxMDAwMDAwMDA3CiNkZWZpbmUgZW5kbCAgICAgJ1xuJwojZGVmaW5lIERFQlVHICAgIGZhbHNlCiNkZWZpbmUgRiAgICAgICAgZmlyc3QKI2RlZmluZSBTICAgICAgICBzZWNvbmQKI3ByYWdtYSBHQ0Mgb3B0aW1pemUgInRyYXB2IgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCgppbnQzMl90IG1haW4oKQp7CiBuaXRybzsKIC8qI2lmbmRlZiBPTkxJTkVfSlVER0UKICAgICAgZnJlb3BlbigiaW5wdXQudHh0IiwiciIsc3RkaW4pOwogICAgICBmcmVvcGVuKCJvdXRwdXQudHh0IiwidyIsc3Rkb3V0KTsKICNlbmRpZiovCiBpbnQgdDsKIGNpbj4+dDsKIHdoaWxlKHQtLSkKIHsKICAgICBpbnQgbjsKICAgICBjaW4+Pm47CiAgICAgc3RyaW5nIHM7CiAgICAgY2luPj5zOwogICAgIGludCBjPTE7CiAgICAgc3RkOjp2ZWN0b3I8aW50PiB2KG4sMCk7CiAgICAgc3RkOjpzdGFjazxwYWlyPGNoYXIsaW50Pj4gc3QxLHN0MjsKICAgICBzdDEucHVzaCh7c1swXSxjfSk7CiAgICAgdlswXT1jOwogICAgIGZvcihpbnQgaT0xO2k8bjtpKyspCiAgICAgewogICAgICAgICBpZihzW2ldPT0nMCcpCiAgICAgICAgIHsKICAgICAgICAgICAgIGlmKHN0MS50b3AoKS5GPT0nMScpCiAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgaW50IGs9c3QxLnRvcCgpLlM7CiAgICAgICAgICAgICAgICAgc3QxLnB1c2goe3NbaV0sa30pOwogICAgICAgICAgICAgICAgIHZbaV09azsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGVsc2UgaWYoc3QyLnNpemUoKT09MCkKICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICBjKys7CiAgICAgICAgICAgICAgICAgc3QyLnB1c2goe3NbaV0sY30pOwogICAgICAgICAgICAgICAgIHZbaV09YzsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGVsc2UgaWYoc3QyLnRvcCgpLkY9PScxJykKICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICBpbnQgaz1zdDIudG9wKCkuUzsKICAgICAgICAgICAgICAgICBzdDIucHVzaCh7c1tpXSxrfSk7CiAgICAgICAgICAgICAgICAgdltpXT1rOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgewogICAgICAgICAgICAgICAgIGMrKzsKICAgICAgICAgICAgICAgICB2W2ldPWM7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgZWxzZQogICAgICAgICB7CiAgICAgICAgICAgICBpZihzdDEudG9wKCkuRj09JzAnKQogICAgICAgICAgICAgewogICAgICAgICAgICAgICAgIGludCBrPXN0MS50b3AoKS5TOwogICAgICAgICAgICAgICAgIHN0MS5wdXNoKHtzW2ldLGt9KTsKICAgICAgICAgICAgICAgICB2W2ldPWs7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBlbHNlIGlmKHN0Mi5zaXplKCk9PTApCiAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgYysrOwogICAgICAgICAgICAgICAgIHN0Mi5wdXNoKHtzW2ldLGN9KTsKICAgICAgICAgICAgICAgICB2W2ldPWM7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBlbHNlIGlmKHN0Mi50b3AoKS5GPT0nMCcpCiAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgaW50IGs9c3QyLnRvcCgpLlM7CiAgICAgICAgICAgICAgICAgc3QyLnB1c2goe3NbaV0sa30pOwogICAgICAgICAgICAgICAgIHZbaV09azsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICBjKys7CiAgICAgICAgICAgICAgICAgdltpXT1jOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQogICAgIGNvdXQ8PGM8PGVuZGw7CiAgICAgZm9yKGF1dG8gaTp2KQogICAgIGNvdXQ8PGk8PCIgIjsKICAgICBjb3V0PDxlbmRsOwogfQogcmV0dXJuIDA7Cn0=