#include <bits/stdc++.h>
using namespace std;
const int nm = 200002;
int n, res[nm];
string s;
void solve() {
  cin >> n >> s;
  stack<int> seq[2];
  int m = 0;
  for (int i = 0; i < n; ++i) {
    int y = '1' - s[i];
    if (seq[y].size()) {
      res[i] = seq[y].top();
      seq[y].pop();
    } else {
      res[i] = ++m;
    }
    seq[1 - y].push(res[i]);
  }
  cout << m << "\n";
  for (int i = 0; i < n; ++i) {
    cout << res[i] << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
