#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    set<int> zero, one;
    int f;
    if (str[0] == '0')
      f = 1;
    else
      f = 0;
    for (int i = 1; i < n; i++) {
      if (str[i] == '0')
        zero.insert(i);
      else
        one.insert(i);
    }
    int sz = 1;
    unordered_map<int, int> m;
    m[0] = sz;
    int idx = 0;
    while ((!zero.empty()) || (!one.empty())) {
      if (idx == (-1)) {
        int z = INT_MAX, o = INT_MAX;
        if (!zero.empty()) z = *(zero.begin());
        if (!one.empty()) o = *(one.begin());
        if (z > o)
          f = 1;
        else
          f = 0;
      }
      if (f) {
        auto pos = one.upper_bound(idx);
        if (pos == one.end()) {
          sz++;
          idx = -1;
        } else {
          f = 0;
          int posi = (*pos);
          one.erase(posi);
          m[posi] = sz;
          idx = posi;
        }
      } else {
        auto pos = zero.upper_bound(idx);
        if (pos == zero.end()) {
          sz++;
          idx = -1;
        } else {
          f = 1;
          int posi = (*pos);
          zero.erase(posi);
          m[posi] = sz;
          idx = posi;
        }
      }
    }
    cout << sz << '\n';
    for (int i = 0; i < n; i++) cout << m[i] << " ";
    cout << '\n';
  }
  return 0;
}
