#include <bits/stdc++.h>
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    int n, i, z = -1, o = -1, s = 0, max = -1;
    scanf("%d", &n);
    char ss[n + 5], at[2];
    scanf("%s", ss);
    int a[n], b[n], zero[n], one[n];
    for (i = 0; i < n; i++) {
      at[0] = ss[i];
      at[1] = '\0';
      a[i] = atoi(at);
    }
    for (i = 0; i < n; i++) {
      if (!a[i]) {
        if (o >= 0) {
          zero[++z] = one[o--];
          b[i] = zero[z];
        } else {
          zero[++z] = ++s;
          b[i] = zero[z];
        }
      }
      if (a[i]) {
        if (z >= 0) {
          one[++o] = zero[z--];
          b[i] = one[o];
        } else {
          one[++o] = ++s;
          b[i] = one[o];
        }
      }
      if (max < b[i]) max = b[i];
    }
    printf("%d\n", max);
    for (i = 0; i < n; i++) printf("%d ", b[i]);
    printf("\n");
  }
}
