#include <bits/stdc++.h>
using namespace std;
char s[200010];
int stack0[200010], top0, stack1[200010], top1, a[200010];
int main() {
  int t, n, i, k;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%s", &n, s + 1);
    top0 = top1 = k = 0;
    for (i = 1; i <= n; i++) {
      if (s[i] == '0') {
        if (top1 > 0)
          stack0[++top0] = stack1[top1], top1--;
        else
          k++, stack0[++top0] = k;
        a[i] = stack0[top0];
      } else {
        if (top0 > 0)
          stack1[++top1] = stack0[top0], top0--;
        else
          k++, stack1[++top1] = k;
        a[i] = stack1[top1];
      }
    }
    printf("%d\n", k);
    printf("%d", a[1]);
    for (i = 2; i <= n; i++) printf(" %d", a[i]);
    printf("\n");
  }
  return 0;
}
