#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y % 2) {
      res *= x;
    }
    y /= 2;
    x *= x;
  }
  return res;
}
long long power(long long x, long long y, long long z) {
  long long res = 1;
  while (y) {
    if (y % 2) {
      res = (res * x) % z;
    }
    y /= 2;
    x = (x * x) % z;
  }
  return res;
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool sortbysec(const pair<long long, long long>& a,
               const pair<long long, long long>& b) {
  return (a.second > b.second);
}
long long ceil(long long x, long long y) { return (x / y) + (x % y != 0); }
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long arr[n];
  long long cur = 0;
  arr[0] = 1;
  stack<long long> o;
  stack<long long> e;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '0') {
      if (o.empty()) {
        e.push(cur + 1);
        arr[i] = cur + 1;
        cur++;
      } else {
        e.push(o.top());
        arr[i] = o.top();
        o.pop();
      }
    } else {
      if (e.empty()) {
        o.push(cur + 1);
        arr[i] = cur + 1;
        cur++;
      } else {
        o.push(e.top());
        arr[i] = e.top();
        e.pop();
      }
    }
  }
  cout << cur << "\n";
  for (long long i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << "\n";
}
int main() {
  fast();
  long long t;
  cin >> t;
  for (long long i = 0; i < t; i++) {
    solve();
  }
}
