#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    vector<int> ans(n);
    vector<int> pos0, pos1;
    for (int i = 0; i < n; i++) {
      int newPos = pos0.size() + pos1.size() + 1;
      if (str[i] == '0') {
        if (pos1.empty()) {
          pos0.push_back(newPos);
        } else {
          newPos = pos1.back();
          pos1.pop_back();
          pos0.push_back(newPos);
        }
      } else {
        if (pos0.empty()) {
          pos1.push_back(newPos);
        } else {
          newPos = pos0.back();
          pos0.pop_back();
          pos1.push_back(newPos);
        }
      }
      ans[i] = newPos;
    }
    cout << pos0.size() + pos1.size() << endl;
    for (int val : ans) {
      cout << val << " ";
    }
    cout << endl;
  }
}
