#include <bits/stdc++.h>
using namespace std;
int ans[200005] = {0};
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    int n;
    cin >> n;
    cin >> s;
    stack<int> a, b;
    int tot = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '0') {
        if (b.size()) {
          ans[i] = b.top();
          int temp = b.top();
          b.pop();
          a.push(temp);
        } else {
          tot++;
          ans[i] = tot;
          a.push(tot);
        }
      } else {
        if (a.size()) {
          ans[i] = a.top();
          int temp = a.top();
          a.pop();
          b.push(temp);
        } else {
          tot++;
          ans[i] = tot;
          b.push(tot);
        }
      }
    }
    cout << a.size() + b.size() << endl;
    for (int i = 0; i < n; i++) cout << ans[i] << ' ';
    cout << endl;
  }
  return 0;
}
