#include <bits/stdc++.h>
using namespace std;
set<int> zeros;
set<int> ones;
int groups[200200];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        zeros.insert(i);
      } else {
        ones.insert(i);
      }
    }
    int group_number = 1;
    for (int i = 0; i < n; i++) {
      if (!groups[i]) {
        groups[i] = group_number;
        int x = i;
        while (1) {
          if (s[x] == '0') {
            if (ones.upper_bound(x) != ones.end()) {
              int v = *ones.upper_bound(x);
              groups[v] = group_number;
              ones.erase(ones.upper_bound(x));
              x = v;
            } else {
              break;
            }
          } else {
            if (zeros.upper_bound(x) != zeros.end()) {
              int v = *zeros.upper_bound(x);
              groups[v] = group_number;
              zeros.erase(zeros.upper_bound(x));
              x = v;
            } else {
              break;
            }
          }
        }
        group_number++;
      }
    }
    cout << group_number - 1 << "\n";
    for (int i = 0; i < n; i++) {
      cout << groups[i] << " ";
    }
    cout << "\n";
    for (int i = 0; i < n; i++) {
      groups[i] = 0;
    }
    zeros.clear();
    ones.clear();
  }
  return 0;
}
