#include <bits/stdc++.h>
using namespace std;
string s;
int a[212345];
queue<int> zero, one;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T, n, i, j;
  cin >> T;
  while (T--) {
    int cnt = 0;
    cin >> n;
    cin >> s;
    for (i = 0; i < n; ++i) a[i] = 0;
    while (!zero.empty()) zero.pop();
    while (!one.empty()) one.pop();
    for (i = 0; i < n; ++i) {
      if (s[i] == '0') {
        if (one.empty()) {
          ++cnt;
          zero.push(cnt);
          a[i] = cnt;
        } else {
          a[i] = one.front();
          zero.push(a[i]);
          one.pop();
        }
      } else {
        if (zero.empty()) {
          ++cnt;
          one.push(cnt);
          a[i] = cnt;
        } else {
          a[i] = zero.front();
          one.push(a[i]);
          zero.pop();
        }
      }
    }
    cout << cnt << endl;
    for (i = 0; i < n; ++i) cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}
