#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n >> s;
    vector<int> b(n + 5), c0, c1;
    for (int i = 0; i < n; i++) {
      int newpos;
      if (s[i] == '0') {
        newpos = c0.size() + c1.size();
        if (c1.empty()) {
          c0.push_back(newpos);
        } else {
          newpos = c1.back();
          c1.pop_back();
          c0.push_back(newpos);
        }
      } else {
        newpos = c0.size() + c1.size();
        if (c0.empty()) {
          c1.push_back(newpos);
        } else {
          newpos = c0.back();
          c0.pop_back();
          c1.push_back(newpos);
        }
      }
      b[i] = newpos + 1;
    }
    cout << c0.size() + c1.size() << endl;
    for (int i = 0; i < n; i++) cout << b[i] << " ";
    cout << endl;
  }
  return 0;
}
