#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
int main() {
  int t, n, i, status[N], grp;
  string str;
  cin >> t;
  while (t--) {
    cin >> n >> str;
    for (i = 0; i < n; i++) status[i] = 0;
    vector<int> v[2];
    grp = 1;
    for (i = 0; i < n; i++) {
      if (str[i] == '0') {
        if (v[0].empty()) {
          status[i] = grp;
          v[1].push_back(grp++);
        } else {
          status[i] = v[0].back();
          v[1].push_back(status[i]);
          v[0].pop_back();
        }
      } else {
        if (v[1].empty()) {
          status[i] = grp;
          v[0].push_back(grp++);
        } else {
          status[i] = v[1].back();
          v[0].push_back(status[i]);
          v[1].pop_back();
        }
      }
    }
    cout << grp - 1 << endl;
    for (i = 0; i < n; i++) {
      cout << status[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
