#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int b;
    cin >> b;
    string s;
    cin >> s;
    int ans = 1, c[2], k[b + 1], m[2];
    k[0] = 1;
    c[0] = 1;
    c[1] = 1;
    m[0] = 1;
    m[1] = 1;
    for (int i = 0; i < b; i++) {
      if (i == 0) continue;
      if (s[i] != s[i - 1])
        k[i] = k[i - 1];
      else {
        if (c[!(s[i] - '0')] > 1) {
          k[i] = c[!(s[i] - '0')] - 1;
          c[!(s[i] - '0')] = max(c[!(s[i] - '0')] - 1, 0);
        } else {
          if (c[!(s[i] - '0')] == 1) {
            c[s[i] - '0'] = m[s[i] - '0'] + 1;
            k[i] = c[s[i] - '0'];
            c[!(s[i] - '0')] = 0;
          } else {
            c[s[i] - '0']++;
            k[i] = c[s[i] - '0'];
          }
        }
      }
      m[s[i] - '0'] = max(m[s[i] - '0'], k[i]);
      ans = max(ans, k[i]);
    }
    cout << ans << endl;
    for (int i = 0; i < b; i++) cout << k[i] << ((i != b - 1) ? ' ' : '\n');
  }
  return 0;
}
