#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
void DBG() { cerr << "]" << '\n'; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << h;
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int> > v(2);
    int ans = 0;
    int p = 0;
    vector<int> ord(n);
    for (char c : s) {
      int id = c - '0';
      if (v[id ^ 1].empty()) {
        ans++;
        ord[p] = ans;
        v[id].push_back(ans);
      } else {
        int who = v[id ^ 1].back();
        v[id ^ 1].pop_back();
        v[id].push_back(who);
        ord[p] = who;
      }
      p++;
    }
    cout << ans << '\n';
    for (int o : ord) cout << o << ' ';
    cout << '\n';
  }
  return 0;
}
