#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  set<long long> s1;
  set<long long> s0;
  long long count = 0;
  long long ans[n];
  string ss = "";
  for (long long i = 0; i < n; i++) {
    if (s[i] == '0') {
      if (s1.size() == 0) {
        count++;
        s0.insert(count);
        ans[i] = count;
        continue;
      }
      long long l = *(s1.begin());
      s1.erase(s1.begin());
      s0.insert(l);
      ans[i] = l;
    }
    if (s[i] == '1') {
      if (s0.size() == 0) {
        count++;
        s1.insert(count);
        ans[i] = count;
        continue;
      }
      long long l = *(s0.begin());
      s0.erase(s0.begin());
      s1.insert(l);
      ans[i] = l;
    }
  }
  cout << count << endl;
  for (auto m : ans) {
    cout << m << " " << flush;
  }
  cout << endl;
}
int main() {
  long long m;
  cin >> m;
  while (m--) {
    solve();
  }
  return 0;
}
