#include <bits/stdc++.h>
using namespace std;
int T, n, be[200005];
char ch[200005];
inline int read() {
  int f = 1, x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
vector<int> p[2];
int main() {
  T = read();
  for (int t = 1; t <= T; t++) {
    p[0].clear(), p[1].clear();
    memset(be, 0, sizeof(be));
    n = read();
    scanf("%s", ch);
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int cur = (ch[i] == '1');
      if (p[cur ^ 1].empty()) {
        ans++;
        be[i] = ans;
        p[cur].push_back(ans);
      } else {
        int tmp = p[cur ^ 1][p[cur ^ 1].size() - 1];
        p[cur ^ 1].pop_back();
        p[cur].push_back(tmp);
        be[i] = tmp;
      }
    }
    printf("%d\n", ans);
    for (int i = 0; i <= n - 1; i++) printf("%d ", be[i]);
    printf("\n");
  }
  return 0;
}
