#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int t, n, a[MAXN];
char s[MAXN];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%s", &n, s + 1);
    queue<int> q[2];
    int cnt = 0;
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; i++) {
      int t = s[i] - '0';
      if (q[1 - t].empty()) {
        a[i] = ++cnt;
      } else {
        a[i] = q[1 - t].front();
        q[1 - t].pop();
      }
      q[t].push(a[i]);
    }
    for (int i = 1; i <= n; i++)
      if (a[i] == 0) a[i] = ++cnt;
    printf("%d\n", cnt);
    for (int i = 1; i <= n; i++) printf("%d ", a[i]);
    puts("");
  }
  return 0;
}
