#include <bits/stdc++.h>
using namespace std;
void i1d(vector<long long> &v) {
  for (auto &i : v) cin >> i;
}
void p1d(vector<long long> &v) {
  for (auto i : v) cout << i << ' ';
  cout << endl;
}
long long t;
void solve() {
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    set<long long> o, z;
    map<long long, long long> ans;
    for (long long i = 0; i <= n - 1; i++) {
      if (s[i] == '0')
        z.insert(i);
      else
        o.insert(i);
    }
    long long ctr = 0;
    long long ptr1 = 0, ptr2 = 0;
    for (long long i = 0; i <= n - 1; i++) {
      if (s[i] == '0') {
        auto it = o.upper_bound(i);
        if (ans.count(i) == 0) ans[i] = ++ctr;
        if (it != o.end()) {
          ans[*it] = ans[i];
          o.erase(it);
        }
      } else {
        auto it = z.upper_bound(i);
        if (ans.count(i) == 0) ans[i] = ++ctr;
        if (it != z.end()) {
          ans[*it] = ans[i];
          z.erase(it);
        }
      }
    }
    cout << ctr << '\n';
    for (long long i = 0; i <= n - 1; i++) {
      cout << ans[i] << ' ';
    }
    cout << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  solve();
}
