#include <bits/stdc++.h>
using namespace std;
int a;
int ling[200005], yi[200005], zy[200005];
char a1[200005];
int main() {
  cin >> a;
  for (int yui = 1; yui <= a; yui++) {
    int head1 = 1, tail1 = 1, head = 1, tail = 1, ling1 = 0, y1 = 0, opi = 0,
        zu = 0;
    scanf("%d", &opi);
    cin >> a1;
    memset(zy, 0, sizeof(zy));
    memset(yi, 0, sizeof(yi));
    memset(ling, 0, sizeof(ling));
    for (int ki = 0; ki <= opi - 1; ki++) {
      char ki1;
      int he;
      ki1 = a1[ki];
      he = ki1 - '0';
      if (he == 0) {
        if (yi[head1] == 0) {
          ling1++;
          ling[tail] = ling1;
          zy[ki] = ling1;
          tail++;
        }
        if (yi[head1] != 0) {
          zy[ki] = yi[head1];
          ling[tail] = yi[head1];
          tail++;
          head1++;
        }
      }
      if (he == 1) {
        if (ling[head] == 0) {
          ling1++;
          yi[tail1] = ling1;
          zy[ki] = ling1;
          tail1++;
        }
        if (ling[head] != 0) {
          zy[ki] = ling[head];
          yi[tail1] = ling[head];
          tail1++;
          head++;
        }
      }
    }
    cout << ling1 << endl;
    for (int y = 0; y <= opi - 1; y++) cout << zy[y] << " ";
    cout << endl;
  }
}
