#include <bits/stdc++.h>
using namespace std;
int t = 0;
void sol() {
  t++;
  int n;
  cin >> n;
  string s;
  cin >> s;
  int mx = 0;
  int x[n];
  deque<int> zero;
  deque<int> one;
  zero.push_back(n);
  one.push_back(n);
  int _0 = 0, _1 = 0;
  bool pas = true;
  if (s[0] == '1') pas = false;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '1') {
      _1++;
      if (pas) zero.push_back(_0);
      pas = false;
      _0 = 0;
      while (true) {
        bool tackle = false;
        if (zero.back() >= _1 || tackle) {
          x[i] = _1;
          break;
        } else {
          zero.pop_back();
          if (one.back() == n) {
            tackle = true;
            continue;
          }
          _1 = one.back() + 1;
          one.pop_back();
        }
      }
    } else {
      _0++;
      if (!pas) one.push_back(_1);
      pas = true;
      _1 = 0;
      while (true) {
        bool tackle = false;
        if (one.back() >= _0 || tackle) {
          x[i] = _0;
          break;
        } else {
          one.pop_back();
          if (zero.back() == n) {
            tackle = true;
            continue;
          } else
            _0 = zero.back() + 1;
          zero.pop_back();
        }
      }
    }
    mx = max(mx, x[i]);
  }
  cout << mx << "\n";
  for (int it : x) cout << it << " ";
  cout << "\n";
}
int main() {
  int tc = 1;
  scanf("%d", &tc);
  while (tc--) {
    sol();
  }
}
