#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    long long ans = 0;
    vector<long long> v(n);
    vector<long long> pos0, pos1;
    for (long long i = 0; i < n; i++) {
      long long curr = pos0.size() + pos1.size();
      if (s[i] == '0') {
        if (pos1.empty()) {
          pos0.push_back(curr);
        } else {
          curr = pos1.back();
          pos0.push_back(curr);
          pos1.pop_back();
        }
      } else {
        if (pos0.empty()) {
          pos1.push_back(curr);
        } else {
          curr = pos0.back();
          pos1.push_back(curr);
          pos0.pop_back();
        }
      }
      v[i] = curr;
    }
    ans = pos0.size() + pos1.size();
    cout << ans << "\n";
    for (long long i = 0; i < n; i++) {
      cout << v[i] + 1 << " ";
    }
    cout << "\n";
  }
  return 0;
}
