#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int nax = 1e5 + 3;
int n;
void solve(int tc) {
  cin >> n;
  string s;
  cin >> s;
  set<int> pos0, pos1;
  vector<bool> used(n, false);
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == '0') {
      pos0.insert(i);
    } else {
      pos1.insert(i);
    }
  }
  int k = 0;
  vector<int> position(n);
  for (int i = 0; i < n; ++i) {
    if (used[i]) continue;
    char prev = s[i];
    int pos = i;
    position[i] = k;
    used[i] = true;
    while (1) {
      if (prev == '0') {
        auto it = pos1.upper_bound(pos);
        if (it == pos1.end()) break;
        used[*it] = true;
        prev = '1';
        pos = *it;
        position[*it] = k;
        pos1.erase(*it);
      } else {
        auto it = pos0.upper_bound(pos);
        if (it == pos0.end()) break;
        used[*it] = true;
        prev = '0';
        pos = *it;
        position[*it] = k;
        pos0.erase(*it);
      }
    }
    ++k;
  }
  cout << k << "\n";
  for (int i = 0; i < n; ++i) {
    cout << position[i] + 1 << " ";
  }
  cout << "\n";
}
int main() {
  int tt = 1;
  scanf("%d", &tt);
  for (int i = 1; i <= tt; ++i) {
    solve(i);
  }
  return 0;
}
