#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    string s;
    cin >> n;
    cin >> s;
    long long visited[n];
    long long ct = 0;
    long long i = 0;
    while (i < n) {
      if (ct > 0) {
        if (s[i] == '1') {
          visited[i] = ct;
          ct++;
        } else {
          ct--;
          if (ct > 0) {
            visited[i] = ct;
          } else
            i--;
        }
        i++;
      } else if (ct < 0) {
        if (s[i] == '0') {
          visited[i] = ct;
          ct--;
        } else {
          ct++;
          if (ct < 0)
            visited[i] = ct;
          else
            i--;
        }
        i++;
      } else {
        if (s[i] == '0')
          ct--;
        else
          ct++;
      }
    }
    long long mx = 0;
    for (long long i = 0; i < n; i++) {
      mx = max(visited[i], mx);
    }
    for (long long i = 0; i < n; i++) {
      if (visited[i] < 0) {
        visited[i] = mx - visited[i];
      }
    }
    mx = 0;
    for (long long i = 0; i < n; i++) {
      mx = max(mx, visited[i]);
    }
    cout << mx << '\n';
    for (long long i = 0; i < n; i++) cout << visited[i] << " ";
    cout << '\n';
  }
}
