#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
double distance(long long x1, long long y1, long long x2, long long y2) {
  return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2) * 1.0);
}
long long factorial(long long n) {
  return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
bool comp(pair<long long, double> a, pair<long long, double> b) {
  if (a.second == b.second) return a.first < b.first;
  return a.second > b.second;
}
const long long X[] = {1, 0, -1, 0, 1, 1, -1, -1};
const long long Y[] = {0, 1, 0, -1, 1, -1, 1, -1};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    char ch;
    vector<long long> v[2];
    long long u = 0;
    vector<long long> a;
    for (long long i = 0; i < n; i++) {
      cin >> ch;
      if (ch == '0') {
        if (!v[1].size()) {
          v[0].push_back(++u);
        } else {
          long long h = v[1].back();
          v[1].pop_back();
          v[0].push_back(h);
        }
        a.push_back(v[0].back());
      } else {
        if (!v[0].size()) {
          v[1].push_back(++u);
        } else {
          long long h = v[0].back();
          v[0].pop_back();
          v[1].push_back(h);
        }
        a.push_back(v[1].back());
      }
    }
    cout << u << '\n';
    for (auto i : a) cout << i << " ";
    cout << '\n';
  }
  return 0;
}
