#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  string st;
  cin >> st;
  stack<long long> stc1, stc2;
  long long x = 0;
  long long res[((long long)(st).size())];
  for (long long i = 0; i < ((long long)(st).size()); i++) {
    if (st[i] == '0') {
      if (stc2.empty()) {
        res[i] = ++x;
        stc1.push(x);
      } else {
        long long val = stc2.top();
        res[i] = val;
        stc2.pop();
        stc1.push(val);
      }
    } else {
      if (stc1.empty()) {
        res[i] = ++x;
        stc2.push(x);
      } else {
        long long val = stc1.top();
        res[i] = val;
        stc1.pop();
        stc2.push(val);
      }
    }
  }
  cout << x << '\n';
  for (long long i = 0; i < n; i++) cout << res[i] << ' ';
  cout << '\n';
}
int main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
