#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 7;
const long long mod = 998244353;
inline long long read() {
  long long x = 0;
  bool f = 0;
  char ch = getchar();
  while (ch < '0' || '9' < ch) f |= ch == '-', ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
void out(long long x) {
  int stackk[20];
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  int top = 0;
  while (x) stackk[++top] = x % 10, x /= 10;
  while (top) putchar(stackk[top--] + '0');
}
int n, vis[maxn], a[maxn];
string s;
int main() {
  int toto = read();
  while (toto--) {
    n = read();
    for (int i = (1); i <= (n); ++i) scanf("%1d", &a[i]);
    memset(vis, 0, sizeof(vis));
    queue<int> q1, q0;
    int ans = 1;
    while (q1.size()) q1.pop();
    while (q0.size()) q0.pop();
    for (int i = 1; i <= n; i++) {
      if (a[i]) {
        if (q0.size() == 0)
          vis[i] = ans++;
        else
          vis[i] = vis[q0.front()], q0.pop();
        q1.push(i);
      } else {
        if (q1.size() == 0)
          vis[i] = ans++;
        else
          vis[i] = vis[q1.front()], q1.pop();
        q0.push(i);
      }
    }
    cout << ans - 1 << endl;
    for (int i = 1; i <= n; i++) cout << vis[i] << " ";
    puts("");
  }
  return 0;
}
