#include <bits/stdc++.h>
using namespace std;
template <typename T>
void pr(vector<T> &v) {
  for (int i = 0; i < (int)(v).size(); i++) cout << v[i] << " ";
  cout << endl;
}
template <typename T>
void pr(vector<vector<T>> &v) {
  for (int i = 0; i < (int)(v).size(); i++) {
    pr(v[i]);
  }
}
template <typename T>
void re(T &first) {
  cin >> first;
}
template <typename T>
void re(vector<T> &a) {
  for (int i = 0; i < (int)(a).size(); i++) re(a[i]);
}
template <class Arg, class... Args>
void re(Arg &first, Args &...rest) {
  re(first);
  re(rest...);
}
template <typename T>
void pr(T first) {
  cout << first << endl;
}
template <class Arg, class... Args>
void pr(const Arg &first, const Args &...rest) {
  cout << first << " ";
  pr(rest...);
  cout << endl;
}
void ps() { cout << endl; }
template <class T, class... Ts>
void ps(const T &t, const Ts &...ts) {
  cout << t;
  if (sizeof...(ts)) cout << " ";
  ps(ts...);
}
void solve() {
  int n;
  re(n);
  string s;
  re(s);
  vector<int> ans(n);
  vector<queue<int>> q(2);
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    int cur = s[i] - '0';
    if ((int)(q[cur]).size()) {
      int j = q[cur].front();
      q[cur].pop();
      ans[i] = j;
      q[(cur + 1) % 2].push(j);
    } else {
      ans[i] = cnt;
      q[(cur + 1) % 2].push(cnt);
      cnt++;
    }
  }
  pr(cnt - 1);
  pr(ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  re(t);
  for (int tt = 0; tt < t; tt++) {
    solve();
  }
}
