#include <bits/stdc++.h>
using namespace std;
void vin(vector<int>& v) {
  int i, p;
  int n = (int)v.size();
  for (i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
}
void vin(vector<long long>& v) {
  long long i, p;
  int n = v.size();
  for (i = 0; i < n; i++) {
    scanf("%lld", &v[i]);
  }
}
void vout(const vector<int>& v) {
  for (auto q : v) printf("%d ", q);
  printf("\n");
}
void vout(const vector<long long>& v) {
  for (auto q : v) printf("%lld ", q);
  printf("\n");
}
struct typ {
  int tp = -1;
  long long a = 0, b = 0;
};
struct comp {
  bool operator()(typ const& a, typ const& b) { return a.a < b.a; }
};
int main(int argc, char const* argv[]) {
  int t = 1;
  cin >> t;
  int co = 0;
  while (t--) {
    int n;
    cin >> n;
    string second;
    cin >> second;
    vector<string> v;
    int i = 0, j = 0, k = 0;
    vector<int> out(n);
    char cur = second[0];
    out[0] = 0;
    v.push_back(second[0] == '0' ? "0" : "1");
    set<int> Z, O;
    second[0] == '0' ? Z.insert(0) : O.insert(0);
    for (i = 1; i < n; i++) {
      cur = second[i];
      if (cur == '0') {
        if (O.empty()) {
          v.push_back("0");
          out[i] = (int)v.size() - 1;
          Z.insert((int)v.size() - 1);
        } else {
          int t = *O.begin();
          O.erase(O.begin());
          v[t] += cur;
          out[i] = t;
          Z.insert(t);
        }
      } else {
        if (Z.empty()) {
          v.push_back("1");
          out[i] = (int)v.size() - 1;
          O.insert((int)v.size() - 1);
        } else {
          int t = *Z.begin();
          Z.erase(Z.begin());
          v[t] += cur;
          O.insert(t);
          out[i] = t;
        }
      }
    }
    int l = (int)v.size();
    printf("%d\n", l);
    for (i = 0; i < n; i++) {
      printf("%d ", out[i] + 1);
    }
    printf("\n");
  }
  return 0;
}
