#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> zero;
    vector<int> one;
    int ans[n];
    int x;
    for (int i = 0; i < n; i++) {
      x = zero.size() + one.size();
      if (s[i] == '1') {
        if (!zero.empty()) {
          x = zero.back();
          zero.pop_back();
        }
        one.push_back(x);
      } else {
        if (!one.empty()) {
          x = one.back();
          one.pop_back();
        }
        zero.push_back(x);
      }
      ans[i] = x + 1;
    }
    int k = zero.size() + one.size();
    cout << k << endl;
    for (int i = 0; i <= n - 1; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
