#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const long long int MOD1 = 1e9 + 7;
const long long int MAX5 = 1e5;
const long long int MAX6 = 1e6;
const long long int MAX7 = 1e7;
const long long int MAX8 = 1e8;
const long long int MAX9 = 1e9;
const long long int MAXX = 1e18;
void solve() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  vector<int> ans;
  ans.resize(n);
  vector<int> nx;
  nx.resize(n);
  stack<int> st;
  for (int ii = 0; ii < n; ii++) {
    if (s[ii] == '0') st.push(ii);
    if (s[ii] == '1' && !st.empty()) {
      nx[st.top()] = ii;
      st.pop();
    }
  }
  while (!st.empty()) {
    nx[st.top()] = -1;
    st.pop();
  }
  for (int ii = 0; ii < n; ii++) {
    if (s[ii] == '1') st.push(ii);
    if (s[ii] == '0' && !st.empty()) {
      nx[st.top()] = ii;
      st.pop();
    }
  }
  while (!st.empty()) {
    nx[st.top()] = -1;
    st.pop();
  }
  int cnt = 0;
  bool vis[2 * MAX5] = {false};
  for (int start = 0; start < n; start++) {
    if (!vis[start]) {
      vis[start] = true;
      int i = start;
      cnt += 1;
      while (true) {
        ans[i] = cnt;
        vis[i] = true;
        if (nx[i] == -1) {
          break;
        }
        i = nx[i];
      }
    }
  }
  cout << cnt << endl;
  for (int ii = 0; ii < n; ii++) {
    cout << ans[ii] << " ";
  }
}
int main() {
  int tttt;
  scanf("%i", &tttt);
  for (int TTTT = 0; TTTT < tttt; TTTT++) {
    solve();
    cout << "\n";
    ;
  }
}
