#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> p0;
    vector<int> p1;
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
      int newpos = p0.size() + p1.size();
      if (s[i] == '0') {
        if (p1.empty()) {
          p0.push_back(newpos);
        } else {
          newpos = p1.back();
          p0.push_back(newpos);
          p1.pop_back();
        }
      } else {
        if (p0.empty()) {
          p1.push_back(newpos);
        } else {
          newpos = p0.back();
          p1.push_back(newpos);
          p0.pop_back();
        }
      }
      ans[i] = newpos + 1;
    }
    cout << p0.size() + p1.size() << endl;
    for (int i = 0; i < n; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
