#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2")
using namespace std;
using lld = long long int;
using pll = pair<lld, lld>;
using lf = double;
using pff = pair<lf, lf>;
using pii = pair<int, int>;
using pli = pair<lld, int>;
using pil = pair<int, lld>;
int n;
char a[200009];
int d[200009];
char st[400009];
int sl;
int main() {
  int i, j, k, l;
  int t = 1, tv = 0;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    scanf("%s", a);
    for (i = 0; i <= n; i++) {
      st[i] = '0';
    }
    sl = n + 1;
    int resp = sl;
    int resq = sl;
    for (i = 0; i < n; i++) {
      if (st[sl - 1] == a[i]) {
        d[i] = sl;
        st[sl++] = a[i];
      } else {
        sl--;
        d[i] = sl;
      }
      if (resp < sl) resp = sl;
      if (resq > sl) resq = sl;
    }
    printf("%d\n", resp - resq);
    for (i = 0; i < n; i++) {
      printf("%d ", d[i] - resq + 1);
    }
    printf("\n");
  }
  return 0;
}
