#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int te;
  cin >> te;
  while (te--) {
    long long int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    vector<long long int> pos(n);
    set<int> se[2];
    for (long long int i = 0; i <= s.size() - 1; i++) se[s[i] - '0'].insert(i);
    while (!se[0].empty() && (!se[1].empty())) {
      int z = 1, last = -1;
      if (*se[0].begin() < *se[1].begin()) z = 0;
      while (1) {
        auto x = se[z].upper_bound(last);
        if (x == se[z].end()) break;
        last = *x;
        pos[*x] = ans + 1;
        se[z].erase(x);
        z ^= 1;
      }
      ans++;
    }
    if ((!se[0].empty()) || (!se[1].empty()))
      ans++;
    else {
      cout << ans << "\n";
      for (auto x : pos) {
        cout << x << " ";
      }
      cout << "\n";
      ;
      continue;
    }
    if (!se[0].empty()) {
      for (auto x : se[0]) pos[x] = ans++;
    }
    if (!se[1].empty()) {
      for (auto x : se[1]) pos[x] = ans++;
    }
    ans--;
    cout << ans << "\n";
    for (auto x : pos) {
      cout << x << " ";
    }
    cout << "\n";
    ;
  }
}
